01 Introduction
setup() and loop()
setup()
The setup() function is called when a sketch starts. Use it to initialize 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()
After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.
Variables are typically defined befor the Setup Function.
The Setup Function is used for commands which are executed only once at the start of the program. Hardware is initialized here and objects are Instantiated.
The Loop Function is unique to Arduino C. Here code is run in an infinite loop.