Free
6 min

Traffic Light 03 — Timed Sequence (TON)

beginnertraffic-lighttimerTONsequences
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_ON

Master power enable

BOOL · %I0.0

Outputs

NS_RED

North-South red lamp

BOOL · %Q0.0

NS_YEL

North-South yellow lamp

BOOL · %Q0.1

NS_GRN

North-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.

  1. #1Green -> yellow -> red, in order

    NS_GRN for 3s, then NS_YEL for 1s, then NS_RED

  2. #2Red holds — no repeat

    Once parked at red, the sequence does not loop back to green

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