Game Flow



    1. To start the game, the user inserts the TOT (stainless steel washer that serves as a token) on the left side of the cabinet.
    2. The rocket on the top of the cabinet starts moving; it signals the passage of time. It reaches the right side after 60s.
    3. The first interaction is to Power the Dome:
      1. The warning LED corresponding to "Power the Dome" game will illuminate.
      2. The user turns the crank. This generates a voltage across a DC motor.
      3. While the user is turning the crank, the power gauge level will increase.
      4. When the power level reaches 100%, the interaction finishes, and the warning LED will go off.
    4. During the rest of the game, the user will encounter 2 possible games: "Shoot Down Meteorites", or "Plug Air Leaks". The active game will be indicated by the warning LED.
    5. Shoot Down Meteorites:
      1. The crisis indicator LED corresponding to "Shoot Down Meteorites" game will illuminate.
      2. On the back panel, the first LED of one of the 3 meteorite banks will turn on. The meteorite will move downwards, closer to the dome.
      3. If the meteorite reaches the dome, the user loses the game.
      4. To shoot down the meteorite the user needs to move the cannon, pointing it towards the meteorite, and then press the blue button to fire the cannon.
      5. When the user presses the blue button, a blue LED on the cannon tip will light. If the meteorite is in range the meteorite will disappear, the knob will vibrate, and the crisis indicator LED will go off.
      Air Leaks:
      1. The crisis indicator LED corresponding to "Air Leak" game will illuminate. The buzzer will also sound at the beginning of the game.
      2. One of the 3 possible fans will turn on.
      3. The oxygen gauge level will start decreasing steadily. If this level reaches zero, the user loses the game.
      4. The user must use their hands to feel for the location of the leak. When they find it, they must insert the plug into the air leak hole. This event will be detected via a hall sensor inside the hole, and a magnet in the plug.
      5. When an air leak is plugged, the fan and the crisis indicator LED will go off.
    6. The user will win the game if they survive 60s or complete a fixed number of interactions. When the user wins the game, they enter to the "Happy Dance" mode. During the "Happy Dance" the cannon moves to each meteorite LED bank and fires "fireworks" (the meteorite LEDs light in a pattern that moves outwards from the Dome).
    7. If the user loses the game, they enter to the "Sad Dance" mode. During the "Sad Dance" the crisis indicator LEDs and the meteorite LEDs closest to the Dome will blink, the cannon "falls" towards one side, and the air and power gauges move to empty.
    8. After the user wins or loses the game, the TOT is returned to the user, and the welcome mode starts. During welcome mode the meteorite LEDs light in a friendly pattern, and the cannon as well as the oxygen and power gauges move from side to side.
    9. If the user does not interact with the game for a period of 30s, the game returns the TOT and goes back to welcome mode.

State Diagrams

There are 10 state machines/services involved:
  1. Arcade FSM: Controls what interactions are to occur.
  2. Global Timer Service: Monitors time for the user to complete game.
  3. Reset Service: Monitors for user interactions with device.
  4. Welcome FSM: Executes welcome mode.
  5. Air Leaks SM: User interaction where the user needs to plug air leaks before oxygen runs out.
  6. Power Crank SM: User interaction where the user needs to turn a crank to generate power for the dome and be able to use the cannon.
  7. Meteor SM: User interaction where the user needs to shoot down meteors.
  8. Cannon SM: Moves the cannon based on an analog input, and gives vibratory feedback when meteor is destroyed.
  9. Button Debounce: Debounces button for firing the cannon.
  10. End Game FSM: Controls the sequence of events for winning or losing the game. Returns the TOT.
There are 5 event checkers:
  1. Pot Checker: Posts New_Pot_Value to Reset_SM and Cannon_SM when user moves the cannon positioning knob.
  2. Button Checker: Posts Button_Down to Debounce when user presses button to fire the cannon.
  3. Crank Checker: Posts Falling_edge or Rising_Edge to Reset_SM and PowerCrank_SM if the user begins or stops moving the crank for power generation.
  4. Air plug Checker: Posts AirflowPlugged to Reset_SM and AirLeak_SM when the user plugs an air leak.
  5. Tot Checker: Checks if TOT was inserted. Posts Tot_Inserted to all.


Diagrams notation: Each box corresponds to a state, the arrows are transitions. The transition notation: Event_name(event_parameter)[Conditions]/ Actions.



Arcade FSM


Global timer


Reset Service


Welcome mode


Air Leak SM


Meteor SM


Cannon SM


Button Debouncer


Power Crank


End of Game FSM




Code and pseudocode listing

In addition to the state machines/services we created the following libraries to interact with hardware:
  1. AirLeakLib: Controls the 3 fans and reads the 3 hall switches. Uses the ShiftRegisterWrite module to control the fans.
  2. Cannon: Reads the potentiometer, positions the cannon, vibrates the knob and lights up the tip LED on the cannon. This module uses the servo library for positioning the cannon. This module uses the AD library to read the potentiometer.
  3. Crisis: Controls the crisis LEDs and buzzer. Uses the SR8 module.
  4. Meteor: Lights up the trace LEDs for the meteors. Utilizes the low level ShiftRegisterWrite_24 module.
  5. PowerLib: Reads the comparator output and controls the power gauge.
  6. Servo: Acts as the low level interface to move the servo motors using PWM functions.
  7. ShiftRegisterWrite: Low level interface to  write to 1 shift register.
  8. ShiftRegisterWrite_24: Low level interface to write to 3 cascaded shift registers.
  9. TOT: Looks for the TOT on insertion and controls the release of it.
Pseudocode Source Code Header File
AirLeakLib.txt AirLeakLib.c AirLeakLib.h
AirLeak_SM.txt AirLeak_SM.c AirLeak_SM.h
ArcadeFSM.txt ArcadeFSM.c ArcadeFSM.h
ButtonDebounce.txt ButtonDebounce.c ButtonDebounce.h
Cannon.txt Cannon.c Cannon.h
Cannon_SM.txt Cannon_SM.c Cannon_SM.h
Crisis.txt Crisis.c Crisis.h
EndGameFSM.txt EndGameFSM.c EndGameFSM.h
GlobalTimer.txt GlobalTimer.c GlobalTimer.h
Meteor.txt Meteor.c Meteor.h
Meteor_SM.txt Meteor_SM.c Meteor_SM.h
PowerCrank_SM.txt PowerCrank_SM.c PowerCrank_SM.h
PowerLib.txt PowerLib.c PowerLib.h
ResetService.txt ResetService.c ResetService.h
ShiftRegisterWrite.txt ShiftRegisterWrite.c ShiftRegisterWrite.h
ShiftRegisterWrite_24.txt ShiftRegisterWrite_24.c ShiftRegisterWrite_24.h
TOT.txt TOT.c TOT.h
WelcomeFSM.txt WelcomeFSM.c WelcomeFSM.h
Servo.txt Servo.c Servo.h
ServoDefs.h