Skip to content
State machine (FSM) templates

State machine — traffic light

Three-phase traffic-light state cycle.

Template previewState machine (FSM)
Traffic light3 states · 3 transitions · 1 eventstimertimertimerRedGreenYellowAll 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 Yellow
initial Red
transition Red -> Green on "timer"
transition Green -> Yellow on "timer"
transition Yellow -> Red on "timer"