Traveling Wave Simulation
Another activity simulates a wave traveling through a medium. In this instance, red represents the area of highest density in the wave, while the orange and yellow LEDs on either side of the red LEDs represent areas of decreasing density.
A function to turn on a block of LEDs in this way is an extension of the traffic light function.
To move the block down the strip of LEDs, it is necessary to first turn off the block that begins at LED 1. The function shown in below uses the Turn off LED function developed for the traffic light program.
Sending the entire block of LEDs forward (Travel_Foward) down the strip of LEDs involves the following steps.
- Set the LED number to 1.
- Repeat 25 times:
- Turn on the LED block.
- Wait a moment.
- Turn off the LED block.
- Increase the LED number by 1.
The steps in sending the LED block back down the strip (Travel_Back) to the beginning is almost the same as Travel_Foward, except that the LED number is decreased by 1 each time through the loop rather than increased.
Once these procedures have been defined, the final program to send the LED block emulating a traveling wave back and forth is straightforward.
There are a number of other physical motions that can be simulated with a strip of LEDs. For example, a vertical strip of LEDs could be used to simulate a bouncing ball.