Arduino Void Setup and Void Loop Functions [Explained]

When you open a new program in the Arduino IDE, you immediately get empty void setup and void loop functions written for you.

void setup() {
  // put your setup code here, to run once:
}
void loop() {
  // put your main code here, to run repeatedly:
}
What are those void setup and void loop functions in Arduino?
In this tutorial I’ll explain to you the role of those functions and how to use them. At the end I’ll also give you some best practices to improve your Arduino programs.
Here is a quick video you can watch as an additional resource to this article:

Void setup and void loop: mandatory functions in Arduino

The Arduino void setup and void loop functions are mandatory. Try to compile a code with one of those functions missing, and you’ll get an error.
# Example of what's happening when there is no void setup() function in your Arduino program
C:\Users\user\AppData\Local\Temp\ccioFeXY.ltrans0.ltrans.o: In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.
Tech Amplifier Final Logo