Making a nested loop repeat before going back to main loop

for(int i = 0; i < 5; i++)

The 'for' says to repeat the statements inside the { } brackets until the expression returns false.

'int i' says define a new integer variable to be used as a simple counter and set it's initial value to 0.
i < 5 is the test for the for expression that is calculated for each time through the enclosed statements are executed, so perform the statements five times (0 to 4 counts of i). i++ means to increment the i variable each time the statements are executed.\

Here is the reference for for: http://arduino.cc/en/Reference/For

That make sense?

Lefty

1 Like