Finite State Machine (cont.)
Example: Traffic lights controller:
- There are four states:
- NG: Green light in the north-south direction.
- NY: Yellow light in the north-south direction.
- EG: Green light at the East-West direction.
- EY: Yellow light at the East-West direction.
- There are four outputs:
- (G;R): North-South green light, East-West red light
- (Y;R): North-South yellow light, East West red light
- (R;Y): North-South red light, East-West yellow light
- (R;G): North-South red light, East-West green light
- There are four inputs:
- (c, c): Car at the North-South, Car at East-West
- (c, nc) Car at North-South, No-car at East-West
- (nc, c): No-car at North-South, Car at East-West
- (nc, nc): No-car at North-South, No-car at East-West