Q:

ASM Chart for synchronous system

I have an ASM chart design problem that I've been stuck on for ages: 
A lift in a building only has a maximum capacity of 2 people. Two sensors detect people entering (input ENTER) and exiting (input EXIT) the lift. A system is required to implement the following conditions: 
a)If more than 2 people enter the lift, an alarm should sound. Otherwise, alarm should not sound. 
b)If there are no people in the lift, the lights should be turned off. Otherwise, the lights should be switched on. 
Assume a maximum of 1 person can enter or exit the lift during any 1 clock cycle. Assume that nobody will try to enter the lift when the alarm is sounding. 
How would i go about producing an ASM chart to describe the conditions above? 
I know this is quite a trivial problem but any help would be much appreciated. 

A:

You'd need four states: "Lift empty", "1 person in lift", "2 persons in lift", "3 persons in lift".
Every time the ENTER signal becomes activated, the state machine has to switch to the next higher state, since one more person is in the lift. (Except when it is in the "3 persons" state because there's no higher state, but nobody will enter the lift when the alarm is sounding anyway)
Every time the EXIT signal is activated, the state machine has to switch to the next lower state, except when it already is in the "empty" state of course.
If none (or both) of the signals are activated, the state machine has to stay in the same state.
If the state machine is in any state except for the "empty" state, it should activate a "LIGHT" output. If it is in the "3 persons" state, it should activate an "ALARM" output as well.

