Arduino Program Structure

 

Arduino programs can be divided in three main parts: Structure, Values (variables and constants), and Functions.

Software structure consist of two main functions:

Setup( ) function

Syntax:

Void setup ( )

{
statements;
}

The setup() function is called when a sketch starts or at the very beginning of the program. 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.

Loop( ) function

Syntax:

Void Loop ( )

{
statements;
}

After creating a setup() function, which initializes and sets the initial values, the loop() function consists the code to be executed and allows your program to change and respond. It is used to actively control the Arduino board.

Here, setup() is preparation, loop() is execution. Both functions are required for the program to work.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s