For Loop
Step 1 - Build the Project
The 'for' loop iterates ,or counts through, one or more commands. The loop will repeat an exact numbers of times; you tell the loop how many times to run before it 'breaks'.
Note: If you're uploading this project directly from the website, first click Run on Arduino, complete the upload, then scroll down and click the Connect button in the Serial Monitor. This allows the data to be sent from the Maker Board to the Serial Monitor.
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
The “for” loop completes a task a set number of times, then completes and exits.
The first part of the loop is the initializer. Usually, that means you create a variable called “i” that will be thrown away after the “for” loop is complete.
The next part of the loop is the condition, where you determine how long you want the “for” loop to run. This is usually a comparator between your variable and a number.
The last part of the “for” loop creation is the way you want the variable to be modified each time the “for” loop runs. Most of the time, you want the variable to count up by one (i++) or count down by one (i –) each time the “for” loop iterates.
The code between the curly braces is what will run while the “for” loop is iterating.