Now you’re going to make one of the eyes flash!
To do this, we need a new function:
loop() { }
The statements in between the braces {...} in loop()
are repeated automatically.
Our example here has a new statement:
delay(500);
The statement “delay(500);
” tells BOB3’s microcontroller to wait 500 milliseconds, i.e. 0.5 seconds.
In line 8, eye 1 is lit in white:
bob3.setLed(EYE_1, WHITE);
Then 500 milliseconds pass:
delay(500);
Then eye 1 is turned off:
bob3.setLed(EYE_1, OFF);
Then another 500 milliseconds pass:
delay(500);
then we go back to line 8...
Compile the new program and transfer it over to your BOB3..
If everything has worked correctly then eye 1 should be flashing!
What do you think would happen if you changed the value 500 in delay()
?
Try changing it to 200, compile your program and transfer it onto your BOB3.
What difference do you notice?
What happens if you change the number to 1000?