Hallway

easy

A doorway is fitted with two light sensors, one on the outside of the door (A) and one on the inside (B). A sensor outputs logic 1 while a person is inside its detection zone and 0 when the zone is clear; the zones are wide enough that a person crossing keeps a sensor asserted for several clock cycles, and close enough that both may be covered at once mid-crossing.

The room has an up/down counter holding how many people are inside. Design the control block that drives it:

  • a full crossing from outside to inside issues one increment

  • a full crossing from inside to outside issues one decrement

  • a person who steps into a zone and backs out the same way must not change the count

The counter and the sensors are given only the control logic is yours to build. Give the state diagram and the counter control signals.