Help! [solved]

Hello guys, I have a doubt among the following statements to my work:

Alternative 1:
"The setup () method contains the code block where the variables to be used in programming are defined and the loop () method contains the code block where the program execution actually happens."

Alternative 2:
"The loop () method contains a block of code that executes infinitely unless the arduino is turned off or is pressed the reset button on the board or a new program is loaded on the platform as well as the setup () method includes the block responsible for creating the initial state of the whole execution of the program code. "

After all, which of the two statements is true? Both seem correct.

Thank you

Fabricio

(deleted)

i am sorry, but, does that means that the alternative 1 is the correct one?

2 is more correct. 1 is confused. "Execution" happens in both setup and loop. It is quite possible to put all the code into setup() and leave loop empty if you only want a thing done once.

Thanks guys, thanks a lot.

The usual way an Arduino program is organized is like this

global variables that can be seen by every function

void setup() {
local variables that only exist within setup
code that runs within setup
}

void loop() {
local variable that only exist within loop
code that runs within loop
}

The function called setup() runs once when the Arduino is reset or started for the first time

The function called loop() is called repeatedly until the Arduino is reset or switched off.

And it would also be normal to create many other functions that are called from loop() or from each other and may also be called from setup().

...R