Datasheet

Your Shield-Bot’s Brain • Chapter 1
Robotics with the BOE Shield-Bot 33
{
// Empty, no repeating code.
}
How the for Loop Works
The figure below shows the for loop from the last example sketch, CountTenTimes. It labels
the three elements in the
for loop’s parentheses that control how it counts.
Initialization: the starting value for counting. It’s common to declare a local variable for the
job as we did here with
int i = 1; naming it i for ‘index.’
Condition: what the
for loop checks between each repetition to make sure the condition is
still true. If it’s true, the loop repeats again. If not, it allows the code to move on to the next
Initialization (start value)
for(int i = 1; i <= 10; i++)
{
Serial.println(i);
delay(500);
}
Condition (repeat again if true)
Increment (step size)