Traffic light simulation
📖 Scenario: You are creating a simple traffic light simulation using a Raspberry Pi. The traffic light has three colors: red, yellow, and green. Each color will be represented by a variable that can be either True (light on) or False (light off).
🎯 Goal: Build a program that simulates the traffic light changing colors in the correct order: red, green, yellow, then back to red. You will create variables for each light, set a timer for how long each light stays on, and print the current light color to the screen.
📋 What You'll Learn
Create three variables named
red, yellow, and green to represent the traffic lights.Create a variable named
light_duration to set how many seconds each light stays on.Use a
for loop to cycle through the traffic light colors in the order: red, green, yellow.Print the name of the light that is currently on.
💡 Why This Matters
🌍 Real World
Traffic lights control vehicle and pedestrian movement safely at intersections. Simulating them helps understand timing and sequencing.
💼 Career
Understanding how to control hardware like LEDs with code is useful for embedded systems and IoT jobs.
Progress0 / 4 steps