The Arduino IDE has several useful features and as we progress through these tutorials, we will explain them in more detail. For today we will start with the main text editing field, where all the code will live. Here you will see that some default text is already present when we opened the application. This includes two blocks of code.
The first is the setup() function and second is the loop() functions. The setup function is a block of code that will run a single time when the Arduino starts. This means when power is applied or when the reset button is pressed, the setup function will execute once.
Then the Loop function begins to execute, and this section of code does exactly what you may think, it executes over and over until the reset button is pressed.
Most microcontrollers usually require a peripheral to be initialized before it can be used. This process of “initializing first” and “then using” corresponds well with the two main functions already created for us. We will need to first initialize the pin we want to use; this will let the microcontroller know that we want to use the GPIO as an output. Then we can use the pin in the loop function to turn on and off.