2.1 Step 1: Identify States, Inputs, and Outputs

The first step in solving a state machine is to identify the possible states, inputs and outputs of the system. In the case of a basic traffic light system there are five states. These states, along with their corresponding encodings, are summarized in Table 2-1.
Table 2-1. Traffic Light State Machine State Table
StateDescriptionBinary Encoding
North/South (N/S) GONorth/South bound traffic can proceed. East/West traffic must stop.000
North/South (N/S) SLOWNorth/South traffic is about to transition to stop state. Traffic should slow down and proceed with caution.001
East/West (E/W) GOEast/West traffic can proceed. North/South traffic must stop.010
East/West (E/W) SLOW East/West traffic is about to transition to stop state. Traffic should slow down and proceed with caution.011
ErrorAn emergency or error has occurred and traffic should stop at the intersection and proceed with caution100
The outputs of the system can also be summarized as in Table 2-2.
Table 2-2. Traffic Light State Machine Output Table
NameDescription
NSG

1 = North/South Green and East/West Red ON

0 = North/South Green and East/West Red OFF

NSY

1 = North/South Yellow and East/West Red ON

0 = North/South Yellow and East/West Red OFF

EWG

1 = East/West Green and North /South Red ON

0 = East/West Green and North/South Red OFF

EWY

1 = East/West Yellow and North/South Red ON

0 = East/West Yellow and North/South Red OFF

ERR

1 = All red lights flashing ON/OFF

0 = No error state

This traffic light system will only have one input to switch the system into the emergency state:
Table 2-3. Traffic Light State Machine Input Table
NameDescription
E

0 = Emergency is not present

1 = Emergency is present