Traffic Light 2-Way
medium
Cycles a two-direction intersection with an all-red safety phase before traffic changes direction.
What it teaches
Keeps Traffic Light Simple’s Enable control, then adds coordination between two directions. The new lesson is the all-red interlock: both directions must close before the other opens.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Enable | BOOL | — | 1 runs the cycle; 0 resets it and shows red in both directions |
| Cfg_GreenTime | DINT | 3000 | Duration of each green phase in milliseconds |
| Cfg_AmberTime | DINT | 1500 | Duration of each amber phase in milliseconds |
| Cfg_AllRedTime | DINT | 2000 | Duration of each all-red safety phase in milliseconds |
| Out_NSGreen | BOOL | — | North-south green light |
| Out_NSAmber | BOOL | — | North-south amber light |
| Out_NSRed | BOOL | — | North-south red light |
| Out_EWGreen | BOOL | — | East-west green light |
| Out_EWAmber | BOOL | — | East-west amber light |
| Out_EWRed | BOOL | — | East-west red light |
Required behavior
- When In_Enable is 0, both directions show red and the sequence resets to its starting phase.
- When In_Enable changes to 1, the cycle starts with north-south green and east-west red.
- The six phases repeat in order: NS green, NS amber, all red, EW green, EW amber, all red.
- Green phases last Cfg_GreenTime, amber phases last Cfg_AmberTime, and all-red phases last Cfg_AllRedTime.
- During every green or amber phase, the other direction is red. During each handover, both directions are red.