Traffic Light 03 — Timed Sequence (TON)
Ready to build this?
Sign up free — no credit card required. This scenario is included in the free tier.
Sign up to play this scenario →Already have an account? Log in
Briefing
Program one approach's full cycle: green for 3 seconds, then yellow for 1 second, then red — chained TON timers and SET/RESET phase bits, no repeat yet. This introduces the exact one-shot POWER_ON AND /INIT guard pattern the final capstone uses, at roughly a third of the full controller's complexity.
Objectives
- POWER_ON true starts NS_GRN for 3 seconds
- NS_GRN times out into NS_YEL for 1 second
- NS_YEL times out into NS_RED, which then holds — no repeat
Hints
- Use two TON timers, one per phase (green, yellow) — declare them in VAR as TON.
- Use SET/RESET (S=/R=) phase bits to track which phase is active, driven by each timer's .Q done-bit.
- Guard the very first SET with a one-shot INIT bit — otherwise the rung that starts green re-fires every scan and the sequence never parks at red.
I/O Table
Inputs
POWER_ONMaster power enable
BOOL · %I0.0
Outputs
NS_REDNorth-South red lamp
BOOL · %Q0.0
NS_YELNorth-South yellow lamp
BOOL · %Q0.1
NS_GRNNorth-South green lamp
BOOL · %Q0.2
Your program will be tested against:
All test cases run automatically when you submit. Assertions are hidden until you pass.
- #1Green -> yellow -> red, in order
NS_GRN for 3s, then NS_YEL for 1s, then NS_RED
- #2Red holds — no repeat
Once parked at red, the sequence does not loop back to green
Related scenarios
Ready to build this?
Sign up free — no credit card required. This scenario is included in the free tier.
Sign up to play this scenario →Already have an account? Log in