Traffic Light
A miniature, fully working traffic-light model for your desk or bedroom. It runs a real 7-phase red→yellow→green cycle on two opposing directions, has a "caution" flashing-yellow standby mode, runs off a rechargeable 18650 cell charged over USB-C, and can double as a night light. Everything — enclosure, PCBs, and firmware — is open: 3D-printable case, two small PCBs you can have fabbed by any board house or make yourself, and ~1KB of AVR C++ running on an ATtiny13A. Every other part is off-the-shelf, available from the usual marketplaces.
Source files — 3 separate repositories
Everything referenced in this build lives across three independent GitHub repos (not one mono-repo) — every link in this article points straight at one of these three:
- TrafficLights_3D_Model — SolidWorks source, STL files (stl/), and pre-sliced print profiles (gcode/)
- TrafficLights_PCB — Altium projects for both boards (TrafficLights/ = main controller, LedsPanel/ = LED panel), schematics, Gerbers, BOMs
- TrafficLights_Attiny13_firmware — the ATtiny13A firmware source (TrafficLight13.cpp) plus build.bat/flash.bat
Difficulty: Difficult
Time:
- ~26 hours unattended printing
- Base ~10h + Top ~1h
- Front panels ~9h
- Reflector stands ~5h
- PCB-Holder clamps ~1h
- ~6 hours active work
- placing/soldering components onto both PCB types ~4h, assuming you ordered bare boards from a fab
- soldering the buttons/battery wiring + crimping connectors ~1h
- wiring the harness and assembling the case ~1h
- if you etch/mill the PCBs yourself instead of ordering them, add
- ~8h for the main board
- ~8h for the 4 LED boards
Total: ~6 (or ~22) hours active work + ~26 hours unattended printing.
Cost:
- ~$18.30 in parts
- ~$10 for bare PCBs (1 order for the controller board, 1 order for the 4 LedsPanel boards — at the usual ~$5/order from PCBWay or similar, not counting shipping)
- ~$2.50 in filament
Total: ~$30.80, not counting shipping. If you etch/mill the PCBs yourself instead, you'll still need copper-clad board plus etching chemicals or milling tools, so it won't end up much cheaper.
Supplies
PCBs:
- TrafficLights_v2 controller PCB (qty 1):
- Gerbers in pcb/TrafficLights/Manufacturing
- LedsPanel PCB (qty 4 per unit):
- Gerbers for a single board: pcb/LedsPanel/Manufacturing_x1
- Gerbers for a 4-up panel: pcb/LedsPanel/Manufacturing_x4
Electronics + hardware, priced (per complete unit, prices approximate as of mid-2026):
- ATtiny13A-SU (qty 1, $1.08) — Main logic MCU. Mouser search
- TC4056A (qty 1, $0.035) — Li-ion battery charger IC. LCSC search · Mouser search
- DW01A (qty 1, $0.014) — Battery protection (over-charge/discharge/short-circuit). LCSC search · Mouser search
- FS8205A (qty 1, $0.10) — Battery protection (over-charge/discharge/short-circuit). LCSC search · Mouser search
- ME2188C50M5G (qty 1, $0.077) — 5V boost converter IC. LCSC search · Mouser search
- BSS84 (qty 1, $0.05) — Power-path switching P-MOSFET. Mouser search
- BAT760-7 (qty 1, $0.056) — Power-path Schottky diode. Mouser search
- LESD5D5.0CT1G (qty 1, $0.006) — USB-C ESD protection diode. LCSC search · Mouser search
- Inductor, 22µH 0603 (MHCI06030-220M-R8) (qty 1, $0.096) — Boost converter inductor. LCSC search · Mouser search
- Capacitor, 10µF polarized (C3) (qty 1, $0.06) — Boost converter input filter capacitor. LCSC search · Mouser search
- Capacitor, 100µF polarized (C4) (qty 1, $0.056) — 5V rail filter capacitor. LCSC search · Mouser search
- Capacitor, 22µF polarized (C5) (qty 1, $0.19) — 5V rail filter capacitor. LCSC search · Mouser search
- Capacitor, 100nF 0603 (C1, C2, C6) (qty 3, $0.006 ($0.002 ea)) — Decoupling capacitor. LCSC search · Mouser search
- Resistor, 0Ω jumper 0805 (R0) (qty 1, $0.001) — USB-C VBUS jumper (0Ω link). Mouser search
- Resistor, 100R 0603 1% (R6) (qty 1, $0.001) — Battery-protection IC support resistor. LCSC search · Mouser search
- Resistor, 150R 0603 1% (R3) (qty 1, $0.001) — Charge-status LED current limiter (red). LCSC search · Mouser search
- Resistor, 1K 0603 1% (R7) (qty 1, $0.001) — Battery-protection IC support resistor. LCSC search · Mouser search
- Resistor, 2K4 0603 1% (R5) (qty 1, $0.001) — Charger IC current-set resistor. LCSC search · Mouser search
- Resistor, 5K1 0603 1% (R1, R2) (qty 2, $0.001 (~$0.0005 ea)) — USB-C CC configuration pull-down. LCSC search · Mouser search
- Resistor, 9K1 0603 1% (R4) (qty 1, $0.001) — Charge-status LED current limiter (green). LCSC search · Mouser search
- Resistor, 10K 0603 1% (R8) (qty 1, $0.001) — Battery-protection IC support resistor. LCSC search · Mouser search
- Resistor, 10K 1206 1% (R9, R10) (qty 2, $0.001 (~$0.0005 ea)) — Mode-button / reset pull-up resistor. LCSC search · Mouser search
- Resistor, 470R 1206 1% (R12, R14) (qty 2, $0.003 (~$0.0017 ea)) — LED current-limiting resistor (yellow). Mouser search
- Resistor, 680R 1206 1% (R11, R16) (qty 2, $0.003 (~$0.0017 ea)) — LED current-limiting resistor (red). Mouser search
- Resistor, 4K7 1206 1% (R13, R15) (qty 2, $0.003 (~$0.0017 ea)) — LED current-limiting resistor (green). Mouser search
- LED, 5mm THT green (GNL-5012GD) (qty 4, $0.44 ($0.11 ea)) — Traffic signal LED. Mouser search · AliExpress search
- LED, 5mm THT red (GNL-5012ED) (qty 4, $0.44 ($0.11 ea)) — Traffic signal LED. Mouser search · AliExpress search
- LED, 5mm THT yellow (GNL-5012YD) (qty 4, $0.44 ($0.11 ea)) — Traffic signal LED. Mouser search · AliExpress search
- USB-C receptacle, 6-pin SMD (qty 1, $0.027) — USB-C power input. LCSC search · Mouser search
- JST XH 2.54mm 2-pin THT header (B2B-XH-A(LF)(SN)) (qty 2, $0.047 ($0.0233 ea)) — Board-side connector (battery / power button). LCSC search · Mouser search
- JST SH 1.0mm 2-pin THT header (BM02B-SRSS-TB) (qty 1, $0.078) — Board-side connector (mode button). LCSC search · Mouser search
- JST SH 1.0mm 6-pin THT header (BM06B-SRSS-TB) (qty 8, $1.38 ($0.173 ea)) — Board-side connector (LED panel link — 4 on main board + 1 per LedsPanel). LCSC search · Mouser search
- Pin header, 2.54mm 6-pin 2-row (ISP) (qty 1, $0.25) — ISP programming header. Mouser search
- JST SH 1.0mm 2-pin cable (qty 1, $0.12) — Mode button signal cable. AliExpress search
- JST XH 2.54mm 2-pin cable (qty 2, $0.26 ($0.13 ea)) — Power button / battery signal cable. AliExpress search
- JST SH 1.0mm 6-pin cable, ~80mm (qty 4, $1.56 ($0.39 ea)) — LED panel interconnect cable. AliExpress search
- Pushbutton, 12mm momentary, backlit (qty 2, $1.30 ($0.65 ea)) — Mode-select / power-status button. AliExpress search
- Resistor, 4.7kΩ (THT) (qty 2, $0.07 ($0.035 ea)) — Button backlight current limiter. Mouser search
- 18650 Li-ion cell, protected (qty 1, ~$4) — Main power cell. AliExpress search
- Lens, PMMA, D20mm, 60° (qty 12, $4.80 ($0.40 ea)) — LED diffuser lens. AliExpress search
- M3 heat-set threaded insert (qty 14, $0.66 ($0.047 ea)) — Case fastening. AliExpress search
- Screw, M3×6 pan head (qty 8, $0.13 ($0.016 ea)) — Case fastening. AliExpress search
- Screw, M3×12 countersunk (qty 5, $0.10 ($0.02 ea)) — Case fastening. AliExpress search
- Screw, M3×20 countersunk (qty 5, $0.15 ($0.03 ea)) — Case fastening. AliExpress search
- Washer, M3 plain (optional) (qty 8, $0.21 ($0.026 ea)) — Case fastening. AliExpress search
Estimated total: ~$18.30 / unit (parts only — excludes bare PCB fab, filament, and shipping).
Printed parts: Base, Top, PCB-Holder ×4, Reflectors, Front Planes.
Material/print-time/settings for each part are in Steps 1–5 below, not repeated here.
Tools:
- 3D printer (or a print service) — ABS, PETG, or "SBS" depending on the profile you pick
- Soldering iron (for the SMD board bring-up, if you're assembling rather than ordering it built)
- USBasp programmer (or an Arduino Nano wired as one) + avr-gcc toolchain
- Small Phillips/hex screwdriver for M3 fasteners
Print the Base
Black parts, printed in eSUN ABS+HS:
- Base — this step
- Top — Step 2
- Front Panels — Step 3
Recommended print settings, same for all three parts, not repeated in Steps 2–3:
- extruder 250°C
- bed 110°C
- layer height 0.2mm
- 6 perimeters
- 5 solid top/bottom layers
- 20% infill
Why black for the case, not the reflectors?
These parts are deliberately printed in black (or another dark, opaque filament) so the case itself doesn't leak LED light through the walls at night — light is only meant to escape through the lens holes in the Front Panels. If you print the structural parts in anything translucent, expect the whole case to glow, not just the signal lenses.
~10 hours, 38g (~15.5m) STL: 3d/stl/TrafficLights.v2-Base.STL · 3MF: 3d/gcode/TrafficLights.v2-Base.3mf
Print the Top
Same black ABS+HS settings as Step 1.
~1 hour, 9g (~4m) STL: 3d/stl/TrafficLights.v2-Top.STL · 3MF: 3d/gcode/TrafficLights.v2-Top.3mf
Print the Front Panels
Same black ABS+HS settings as Step 1.
Three plain panels, one with the USB-C cutout. At the settings above, printing all 4 takes ~9 hours, 52g (~20.5m).
STL:
- 3d/stl/TrafficLights.v2-Front_x3.STL — 3 copies of the plain panel bundled in one file (not 3 complete units — you need this file once)
- 3d/stl/TrafficLights.v2-Front_USB_x1.STL — the 4th (USB-cutout) panel, only 1 needed
3MF (all 4 at once):
Slicer tweak for the Front Panels specifically: at layer 13 (2.4–2.6mm) turn on ironing for top surfaces, then from layer 14 up (>2.6mm) drop to 0.1mm layer height. This smooths out the contour of the panels' sun-visor-style hoods over the lenses.
Print the PCB-Holders
Despite the name, the "PCB-Holder" parts aren't for the controller board — they're the small clamps that hold each LedsPanel board onto its lamp-rail stand (2 screws per clamp, one clamp per panel).
White/light-colored parts (PCB-Holder, this step; Reflectors, Step 5) use SBS or another low-shrinkage material (PETG etc.). Recommended print settings, same for both, not repeated in Step 5:
- layer height 0.2mm
- 6 perimeters
- 5 solid top/bottom layers
- 20% infill
- for SBS specifically: extruder 250°C / bed 90°C
Why white for these parts? They work as reflectors for the signal LEDs — you could paint the inside of the lens cups with silver paint instead, but plain white plastic is good enough; that's what the original build used.
Low shrinkage matters too: the LEDs are soldered onto the board first, then the printed cups have to slip over them — if you use a higher-shrinkage material, the holes may not line up and you'll need to rework the fit by hand.
(one unit's worth) — ~1 hour 10 minutes, 9g (~3.5m) STL: 3d/stl/TrafficLights.v2-PCB-Holder_x4.STL · 3MF: 3d/gcode/TrafficLights.v2-PCB-Holder_x4.3mf
Print the Reflectors
Same white/SBS settings as Step 4.
(top/bottom + top-only variants — one unit's worth) — ~5 hours, 38g (~15.5m) STL: 3d/stl/TrafficLights.v2-Reflector-Top-Bottom_x2.STL + 3d/stl/TrafficLights.v2-Reflector-Top.STL + 3d/stl/TrafficLights.v2-Reflector.STL · 3MF: 3d/gcode/TrafficLights.v2-Reflectors_All.3mf
Filament totals, one complete unit:
- Black (eSUN ABS+HS): 100g (~40m) — ~$1.50 at ABS+HS's typical ~$15/kg
- White (SBS): 50g (~20m) — ~$0.95 estimated (no solid per-kg SBS price found; ~$20/kg assumed,
- Total filament: ~150g (~60m), ~$2.50
Melt the M3 Brass Inserts Into the Reflector Stands
Heat-set the M3 brass threaded inserts into the printed reflector stands (from Step 5) with a soldering iron or dedicated heat-set tip, before assembly — much easier to do now than once the LEDs and lenses are in place.
Order the Controller Board
Send the Gerbers to a board house, or use them to etch/mill the board yourself: pcb/TrafficLights/Manufacturing/
Schematic/BOM/3D preview are in the board's Doc/ folder:
Order the LedsPanel Boards
Gerbers:
- pcb/LedsPanel/Manufacturing_x1/ for one board at a time (you need 4 per unit)
- pcb/LedsPanel/Manufacturing_x4/ for a 4-up panel
Schematic/BOM/3D preview are in the board's Doc/ folder:
Solder the Controller Board
Solder the components per the schematic in TrafficLights_v2.pdf.
Solder the LedsPanel Boards
Solder the components per the schematic in LedsPanel.pdf.
Flash the Firmware
The firmware (firmware/TrafficLight13.cpp) targets the ATtiny13A directly — 1024 bytes flash, 64 bytes RAM. You'll need avr-gcc and a USBasp programmer (plugs into the same header used for ISP, shared with two of the LED I/O pins). The controller board needs to be soldered up first (Step 9) — flashing happens through its ISP header, with the ATtiny13A already in place.
Check the USBasp's own jumpers before connecting anything — this one has:
- a 3.3V/5V select jumper (JP2) — the ATtiny13A here runs off the board's 5V rail
- a slow-programming-speed jumper (JP3)
Connect it to the controller board's ISP header (a 6-pin IDC-to-2.54mm adapter is the easiest way to go from the USBasp's 10-pin header down to the board's 6-pin JST-style ISP pins):
That confirms the write succeeded, but it's flash.bat's output, not build.bat's — it doesn't show the actual size report (flash/RAM used vs. the 1024B/64B budget). Worth capturing that separately too: run build.bat and grab the avr-size line it prints.
More detail on how the state machine works (it's a single PROGMEM table driving all 10 lighting states) is in the firmware repo's README, or in even more depth in the original author's Habr article (in Russian), if you want to understand or modify it.
Fit the LED Panels Into Their Stands
The assembled stands look like this.
Wire the Buttons and Prep the Battery
Two separate sub-assemblies shown together in one photo, since both need their wire ends crimped onto connectors (not attached to each other yet):
- The two buttons, wired into the Top part (with the backlight resistors), with their own connectors
- The battery, with its connector
Wire the Harness and Connect Everything
Everything plugs into the controller board here — all 4 LED stands, both buttons, and the battery:
All connectors here are keyed (they only go in one way), but that only protects you at the connector housing — it's still worth knowing which lines actually care about polarity:
Polarity matters:
- Battery → SW-BAT (JST XH 2.54mm, 2-pin)
- Button backlights (LED-based) → +5V and GND from the J-USBASP header, through two 4.7kΩ resistors, shared by both buttons in a small daisy chain — red/black wires and +5V/GND labels on the diagram
- 4× LedsPanel boards → the four 6-pin JST SH 1.0mm headers (+J-WE1, .J-WE2, +J-NS1, .J-NS2), ~80mm cross-wired cables, one per panel — see the diagram for which panel goes where
Polarity doesn't matter:
- Mode button signal (normally-open) → SW-CTL (JST SH 1.0mm, 2-pin) — it's just a switch contact that closes the loop, marked "polarity doesn't matter" on the diagram
- Power/status button signal (normally-open) → SW-PWR (JST XH 2.54mm, 2-pin) — same
Prep the Front Panels With Lenses
Set the Controller Assembly Into the Base
Fix the Front Panels One at a Time
Fix the first three front panels onto the Base one at a time, screwing each down before moving to the next. Prepare the fourth panel — the one with the USB-C cutout — the same way, but don't fix it in place yet: it goes in later, in Step 19, after the battery is in.
Drop the Battery In
Install the Fourth Front Panel
Install the Top and Close the Case
Assembly Video
Watch the assembly on YouTube if anything from Steps 9–20 is still unclear.
Using & Credits
Using it
- Power switch (the "state" button) cuts power completely — no standby drain.
- Short-press the mode button to toggle between the normal 7-phase cycle and the flashing-yellow caution mode.
- Charge over USB-C, 5V/500mA — the front LED shows charging (red) vs. ready (green).
Credits
- The firmware and circuit design are adapted from Archy_Kld's Habr article "Three eyes hang on a pole..." — see firmware/README.md for the full attribution and what was changed.