Moving an LED across the Strip
A program to create a blinking LED can be defined in this manner:
- Turn on an LED.
- Wait a moment
- Turn off the LED.
- Wait a moment.
The function Blink defined in this manner is illustrated in Figure 19 below. In this mBot program, a Forever loop is used to cause LED 15 to blink forever (or until another command is executed).
If the command Turn_On LED is replaced with Blink_LED, a traveling LED can be created that travels the length of the LED strip. Compare the All_On function with the Traveling LED function below. They are identical except for one line.
The second delay statement (Wait 0.1 Seconds) is not needed when the Blink function is used in the Traveling_LED procedure. It just slows down the movement of the LED as it travels down the strip. A variant of Blink named Flash omits the second Wait statement. This adjustment results in a more fluid movement of the LED as it travels across the strip.