Structure of Arduino Program:

Arduino programs consists of three main parts:

  • Structure
  • Values (variables and constants), and
  • Functions.

Every Arduino Program is fasciliated with to function by default, those are:

  1. void setup ()
  2. void loop ()

Following figures shows the void setup() function and void loop function

Structure of Program

void setup() function:

The setup() function is called when a sketch starts. It is used to initialize the variables, pin modes, start using libraries, etc. The setup function will only run once, after each power up or reset of the Arduino board.

void setup() {
  // put your setup code here, to run once:


void loop() function:

The loop() function does precisely what its name suggests, and loops consecutively, allowing the program to change and respond. This is actively used to control the Arduino board.

void loop() {
  // put your main code here, to run repeatedly: