DEV Community

Cover image for Arduino Giga R1 WiFi Traffic Light
Arduino ESP32 Raspberry Pi Tutorials
Arduino ESP32 Raspberry Pi Tutorials

Posted on Originally published at newbiely.com

Arduino Giga R1 WiFi Traffic Light

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

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
Enter fullscreen mode Exit fullscreen mode

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)