A traffic light module packs three LEDs - red, yellow, green - into one part, and this build drives them from an Arduino Giga R1 WiFi. It's a nice first hardware project if you're used to writing state machines in code: you turn that logic into actual GPIO pin toggles and timing, running the same red, red+yellow, green, yellow sequence used at real intersections.
The full tutorial, with every detail and the line-by-line code explanation, is on our site: Arduino Giga R1 WiFi Traffic Light
What you need
- Arduino Giga R1 WiFi
- USB Cable Type-A to Type-C (for USB-A PC)
- USB Cable Type-C to Type-C (for USB-C PC)
- Traffic Light Module
- Jumper Wires
- Screw Terminal Block Shield for Arduino Uno/Mega/Giga
- Sensors/Servo Expansion Shield for Arduino Mega/Giga
- Breadboard Shield for Arduino Mega/Giga
- Enclosure for Arduino Giga
- Power Splitter for Arduino Giga
- DIYables Sensor Kit (18 sensors/displays)
How it works
The module has four pins: GND, R, Y and G. Connect GND to the Arduino's GND first, to give all three LEDs a common return path before anything else is powered. Then connect R, Y and G each to their own Arduino digital output pin. Any digital pin works for any color, since the module has current-limiting resistors built in, so you don't need extra resistors on the breadboard.
Code
digitalWrite(PIN_RED, HIGH); // turn on RED
digitalWrite(PIN_YELLOW, LOW); // ensure yellow is off
digitalWrite(PIN_GREEN, LOW); // ensure green is off
delay(RED_TIME); // maintain red state for specified duration
Full tutorial
The complete tutorial - wiring diagram, code explanation and troubleshooting - is here: https://newbiely.com/tutorials/arduino-giga/arduino-giga-r1-wifi-traffic-light
Top comments (0)