Create a Traffic Light With a Flashing Yellow Light

by Protobject in Teachers > 6

49 Views, 1 Favorites, 0 Comments

Create a Traffic Light With a Flashing Yellow Light

ezgif.com-optimize (1).gif

In this project, you'll create a realistic traffic light simulation with a flashing yellow phase using Protobject, a web-based platform. This interactive system runs in an infinite loop, mimicking the behavior of an actual traffic light. No extra hardware is needed—just a smartphone and a computer!

With this simulation, you can visualize the full traffic light cycle, including the flashing yellow light before switching to red.

Supplies

  1. 1 Smartphone (used as the traffic light controller)
  2. 1 Computer (to access Protobject and configure the system)
  3. (Optional) Paper Road (to create a mini traffic scene)
  4. (Optional) Small Toy Car (to make the simulation more interactive)
  5. (Optional) Cardboard Stand (to hold the smartphone upright like a real traffic light)

Access the Protobject Platform

msedge_jQJfPmKIPk.png

Open the Protobject platform at https://app.protobject.com using Chrome or any Chromium-based browser (e.g., Edge, Opera).

No sign-up or login required—just open the link and start experimenting!

Add Devices

msedge_vFkmaPrrt4.png
  1. Add the Lamp device by opening it on your smartphone.

Program the Traffic Light Simulation

msedge_CeSsILOu7K.png

How It Works

The simulation follows a structured traffic light cycle:

  1. The system runs in a continuous loop, replicating real-world traffic light behavior.
  2. Inside the loop, a nested sequence controls the flashing yellow light.
  3. The flashing effect is achieved by alternating between on and off states.
  4. After flashing, the light switches to red, completing the traffic light cycle.

Open the pre-configured project or view the code with comments explaining each detail.

Test Your Traffic Light

  1. Create the project and press the Play button.
  2. Use your smartphone as the traffic light display.
  3. (Optional) Create a cardboard stand to hold your smartphone vertically like a real traffic light.
  4. (Optional) Place a paper road and toy car to simulate a real scenario.
  5. Watch the yellow light flash before the transition to red.

Optional Enhancements

🔊 Sound Effects: Add sounds for each light change to simulate real traffic signals. To achieve this, you may use the MusicalKeyboard component.

Countdown Timer: Display the remaining time before the light changes by using the WriteDraw component to show numbers.

🚦 Add Another Traffic Light: Set up a second smartphone to display an additional traffic light, simulating a real intersection with alternating signals, just like in a functioning traffic system.

With Protobject, you can quickly prototype and design interactive systems without extra hardware.

Happy coding!