Lab 3

We are going to add an infrared (IR) LED and an infrared receiver to the arduino. We already know how to add an LED, and we have chosen to put it on pin 10. The new part is the infrared receiver. This outputs whether or not it sees an infrared signal turning on and off 38,000 times a second. We need to give this sensor power, ground, and connect its output wire to our arduino so that our arduino can sense the signal (high or low voltage) that the infrared sensor gives as an output. Below is a circuit diagram of what we need to add.

Figure 1: Picture of connections. (Click on the picture to make it bigger).

Lab3_bb
Note: I couldn't find an IR sensor in the software I use to draw circuits, so my IR sensor doesn't look exaclty like an IR sensor.

So, now that we have a red LED, infrared LED, infrared sensor and button, how do we want to program them? So, for laser tag, we want to push a button and send a signal out of our infrared LED (to send a tag). When we receive a tag on our infrared receiver, we want to indicate that we have been tagged with our red LED. So, we need to modify our code to follow those instructions.

We are going to use other people's code to make building laser tag easier. We call other people's code libraries. It is sort of like checking out a book at the library, only you are checking out other people's code and using it in your own code.

The first library that we are going to use will turn on and off our infrared LED 38,000 times a second. That library is called TimerOne. You can download the library here (note, download the file TimerOne-r11.zip for the latest version) and read about how it works with the TimerOne Tutorial (the tutorial on how it works is very advanced. I can go over it later if you would like. You do not need to know the details on how it works to use it properly).

Once you have the file downloaded, you need to tell the arduino programming software where the library is so that you can use it in your code. The arduino software has a folder where it stores all of the libraries it knows about. To move the library to a place where the arduino software can find it, you can follow the tutorials from either the arduino library installation or the sparkfun library tutorial. Once you have the TimerOne library installed, it's time to modify the code to make a rudimentary laser tag unit. To the code!

Leave a Reply

Your email address will not be published. Required fields are marked *