Setup and Loop functions in Arduino - Arduino tutorial

Setup() in Arduino:

As the name suggest this function is used to setup the input, output pins in the arduino word. In this function  you can do the serial initialization also.

Function prototype:

void setup() {
//Initialize
}

Functions used inside setup():

Serial.begin(baudRate); // Initialize serial communication at given baudRate
pinMode(pinNumber,INPUT); //Initialize pinNumber as a input
pinMode(pinNumber,OUTPUT); //Initialize pinNumber as a output

Loop() in arduino:

This function is a super loop in the arduino world. This loop has life as like as the supply to the controller has. This loop will be executed infinite times. It is similar to while(1) and for(;;) in c and c++.  

while(1){                                                     void loop() {
 //your functions                  ==                       //your funcions    ==   for(;;)
}                                                                   }


Cheers!!!!
-> Let Us Embed <-