TARGETS

The Target Module is programmed to handle all events that involve tracking if a target has been hit.

Click here to see the hardware setup of the Targets

Click here to see and download the complete Target.h module

Click here to see and download the complete Target.c module

Public Level Functions:

Function: initTargets(void)
Description: Initializes the target module
Input: None
Output: None
Psuedocode: Reseed the random number generator with the current time
Set no target as active
Initialize 0-0 score
Initialize target selection timer

Function: checkTarget1(void), checkTarget2(void)
Description: Check to see if the active target has been legally hit
Input: None
Output: Unsigned char 1 for yes, 0 for no
Psuedocode: If no target is active, return 0
Read A/D port from photocell
If gun is firing and light is above threshold
return 1
return 0 otherwise

Function: registerHit1(void), registerHit2(void)
Description: Registers a valid target hit by updating score and deactivating current target
Input: None
Output: None
Psuedocode: Turn off LED
Set active target as -1 (no active target)
Increment score
Initialize target selection timer on a decreasing linear scale (based on total # targets hit)
Turn on vibrate motor

Function: checkActiveTarget(void)
Description: Checks to see if a new target needs to be activated
Input: None
Output: Unsigned char 1 for yes, 0 for no
Psuedocode: Returns if the target selection timer is expired

Function: score1(void), score2(void)
Description: Returns each player’s score
Input: None
Output: Unsigned char score
Psuedocode: Return number of targets hit by that player
   
Function: endTarget(void)
Description: Deactivates the LED at the end of the game
Input: None
Output: None
Psuedocode: Turn off LED