Skip to content
State machine (FSM) templates

Traffic Light (State Machine)

The cyclic states of a traffic light.

Template previewState machine (FSM)
Traffic light3 states · 3 transitions · 1 eventstimertimertimerRedGreenAmberAll 3 states are reachable and every transition names states that exist.INFONo state is marked `final`, so this machine never terminates. That is ordinary for a reactive controller and a smell for a workflow.OKAll 3 states are reachable from `Red`.OKAll 3 transitions name states that exist, so every arrow in the figure is drawn.

Make it your own.

title "Traffic light"
state Red
state Green
state Amber
initial Red
transition Red -> Green on "timer"
transition Green -> Amber on "timer"
transition Amber -> Red on "timer"