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.

The Colors in the Block of LEDs Represent Areas of Density in a Wave

A function to turn on a block of LEDs in this way is an extension of the traffic light function.

Turning On a Block of Five LEDs

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.

Turning Off a Block of LEDs

Sending the entire block of LEDs forward (Travel_Foward) down the strip of LEDs involves the following steps.

  1. Set the LED number to 1.
  2. Repeat 25 times:
    • Turn on the LED block.
    • Wait a moment.
    • Turn off the LED block.
  3. Increase the LED number by 1.
Sending the Block Forward Down the Strip of LEDs and Back

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.

The Final Traveling Wave Program

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.