Traffic Light¶
A sequential Red → Green → Yellow → Red controller using OTL/OTU latch logic.
Ladder Diagram¶
Rung 0: Initialize — if no state active, latch Red
──[/B:0/0 ]──[/B:0/1 ]──[/B:0/2 ]──(L B:0/0 )──
StateRed StateYellow StateGreen Latch Red
Rungs 1-2: Red → Green transition (manual button)
──[ B:0/0 ]──[ I:0/1 ]──(U B:0/0 )── ; Unlatch Red
──[ B:0/0 ]──[ I:0/1 ]──(L B:0/2 )── ; Latch Green
Rungs 3-4: Green → Yellow transition
Rungs 5-6: Yellow → Red transition
Rung 7: Red light output
──[ B:0/0 ]──( O:0/0 )──
Rung 8: Yellow light output
──[ B:0/1 ]──( O:0/1 )──
Rung 9: Green light output
──[ B:0/2 ]──( O:0/2 )──
I/O Assignment¶
| Address | Description |
|---|---|
I:0/1 | Advance button |
B:0/0 | Red state |
B:0/1 | Yellow state |
B:0/2 | Green state |
O:0/0 | Red light |
O:0/1 | Yellow light |
O:0/2 | Green light |
Tip
Open examples/traffic-light.plcproj in PiPLC to try this program. You can replace the manual button with timers for automatic sequencing.