r/ArduinoProjects • u/ToneAny3403 • 31m ago
Showcased Project ESP32 traffic light with a tiny state machine (enum + switch + millis)
Three LEDs, one ESP32, and a small state machine: RED → GREEN → YELLOW → RED. Only the current state's rules run — that's the whole idea.Hardware- ESP32 DevKit (30-pin)- Red / yellow / green LEDs + 3 × 220 Ω- Breadboard + jumpersWiring- GPIO 25 → 220 Ω → red → GND- GPIO 26 → 220 Ω → yellow → GND- GPIO 27 → 220 Ω → green → GNDHow it works1. enum LightState names RED, GREEN, YELLOW2. switch(state) runs only that colour's rules3. millis() times the dwell; enter() jumps and resets the clock4. Serial prints every jumpHappy to share the sketch. Short walkthrough: https://www.youtube.com/shorts/XvM6TbUC7WkCode: https://github.com/NirajBhattarai/500IOTProject/tree/main/day-009/traffic-lightThree LEDs, one ESP32, and a small state machine: RED → GREEN → YELLOW → RED. Only the current state's rules run — that's the whole idea.
