Basic
6 min

Traffic Light 02b — Green then yellow

traffic-lighttimerTONsequencesfundamentals

Ready to build this?

Sign up free — no credit card required. This scenario requires the Basic plan.

Sign up to play this scenario →

Already have an account? Log in

Traffic Light 02b — Green then yellow

Briefing

Now a timer changes the light, not a switch. The light rests on red. A GO pulse turns it green; after 3 seconds green ends and yellow begins. RESET_PB puts it back to red. Only one lamp is lit at a time. Red shows whenever neither green nor yellow is on.

Objectives

  • Idle: red on, green and yellow off
  • GO: green on, red off
  • After 3 seconds: green off, yellow on, red still off
  • RESET_PB: back to red

Hints

  • Think of three states: red, green, yellow. Which input moves you out of red, and what moves you on from green?
  • Moving on from green needs time. A TON on-delay timer, running while green is lit, tells you when 3 seconds have passed.
  • When the timer finishes, one lamp must end and the next must begin. Red should never light while either of them is on.
  • RESET_PB only has to end yellow; red then follows from the others being off. PT is in milliseconds.

I/O Table

Inputs

GO

Go push-button (momentary NO)

BOOL · %I0.0

RESET_PB

Reset push-button (momentary NO)

BOOL · %I0.1

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. #1Idle → red only

    With nothing pressed, only the red lamp is on

  2. #2GO → green on, red off

    GO starts the green phase

  3. #3After 2.5 s → still green

    Green holds for its full 3 seconds

  4. #4After 3.4 s → yellow on, green and red off

    The timer ends green and starts yellow

  5. #5RESET → red again

    RESET_PB returns the light to red

  6. #6After a reset, GO runs a full green phase again

    A second cycle: green holds 2.5 s then turns yellow

Ready to build this?

Sign up free — no credit card required. This scenario requires the Basic plan.

Sign up to play this scenario →

Already have an account? Log in