Spring 2016 3 DOT Goliath IR sensor Code

By: Tae Lee (Systems Engineer)

IR Sensor Code

To implement the laser tag game we have to show an indication of when the Goliath gets hit by the enemy’s IR LED. This will be shown through the three LEDs we will be using to indicate the number of hits.

The following code shown below will be used to implement the three hit indicator:

IR code1


IR code 2

The general idea of how this code operates will be shown by the block diagram below:


IR code 3

The code will start by checking if a signal is received at the detector. If the detector detects the IR emitter it will light up one of the LEDs and increases the count. The count will be used to indicate the number of hits received by the enemy. As we get hit the count will increase to power each LED until it reaches 3 hits. The if statement will be used to check if the Goliath receives 3 hits, which will disable the Goliath. Otherwise, it will do nothing and it will repeat the program through a loop.