Traffic Light Simple
medium
Drive a one-way traffic light through red, green, and amber phases on a timer.
What it teaches
Move through a fixed sequence of phases — red, then green, then amber, then back to red — each held for a set time. One repeating timer paces the whole cycle, and you light each output by comparing the elapsed time against that phase's cutoff. The skeleton behind every wash cycle, batch process, and motion routine.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Enable | BOOL | 1 | — |
| Cfg_RedTime | DINT | 5000 | — |
| Cfg_GreenTime | DINT | 5000 | — |
| Cfg_AmberTime | DINT | 2000 | — |
| Out_Red | BOOL | — | — |
| Out_Green | BOOL | — | — |
| Out_Amber | BOOL | — | — |
Required behavior
- When In_Enable is 0, the sequence is disabled and outputs revert to Out_Red=1, Out_Green=0, Out_Amber=0.
- When In_Enable is 1, outputs cycle endlessly through Red, Green, and Amber states.
- Red phase lasts for Cfg_RedTime milliseconds, asserting Out_Red.
- Green phase lasts for Cfg_GreenTime milliseconds, asserting Out_Green.
- Amber phase lasts for Cfg_AmberTime milliseconds, asserting Out_Amber.