Hardware Reference
In-Depth Information
means the processor will add one to the i value at the end of each loop. This will
be looped five times for i equals to 0, 1, 2, 3, and 4. The check statement will fail
when i equals 5 and the loop will stop.
{ : This bracket defines the start of the statements that may be looped.
digitalWrite(led, HIGH); : The statements that will be executed each
time through the loop and flash the LED light quickly are delay(100); , di-
gitalWrite(led, LOW); , and delay(100); .
} : This ends the loop. When this statement is reached each time through the loop,
the loop statement is executed and the execution goes back to the top of the loop,
where the check statement is evaluated. If it is true, the statement is executed
again. If it is false, the loop stops and the statement following the loop is ex-
ecuted.
for (int i = 0; i < 5; i++) : This is another loop, just like the previ-
ous one, except it flashes the LED for a long time. Just like the first loop, it is ex-
ecuted five times.
{ : This bracket defines the start of the statements that may be looped.
digitalWrite(led, HIGH); : The statements that will be executed each
time through the loop and will flash the LED light quickly are delay(1000); ,
digitalWrite(led, LOW); , and delay(1000); .
} : This ends the loop.
Now you can upload the program and see that there are five long flashes of the orange
LED followed by five short flashes.
Search WWH ::




Custom Search