Apr 18

Board to use for permanent Laser Tag modules

I would like to have a stand-alone board to put in the laser tag modules instead of an arduino. This would allow students to use the arduino that they use in class for other projects while keeping the laser tag module intact. Right now I have two alternatives:

Moteino: Cost: $18.95. Uses surface mount components for a really small footprint (1.3x0.9 inches), ATMega328P processor, RFM12B tranceiver. This is the lowest cost module that I could find (as opposed to the JeeNode, which is 18 euros, and has a much larger footprint). I would need an FTDI adapter (or just use the one in the arduino to program it) to program the module, but that's fine. The Moteino also has a version without the RFM12B, which is $12.95.
Update: Low Power Lab is working on an ATMega32u4 based Moteino called the Moteeino Leo, which will probably be less expensive (since it's USB native). Keep an eye out for this.

Freakduino: Cost: $33. Freakduino is an open source arduino clone with an on board 2.4GHz radio (the Atmel AT86RF230). It has a great datasheet, and is a bit bigger than a standard arduino. It's a little pricier, but I like that it can have a longer range by adding an antenna.

miniSWARM: Cost: $25. miniSWARM is an open source arduino compatible with a 2.4GHz radio built into the chip. As of this posting, it is on Indiegogo for crowd funding. It can be used to build a mesh network and is based on the ATmega128RFA1. They are also giving away some miniSWARMs away on their website. This module has much more capability than I need for my application, but it may be useful if I want a mesh network and a much more complicated game.

Note: Both of these alternatives have built in radios for communicating with a central hub, which would keep track of tags. I could not have a wireless module and have all the communication between the central hub, bases, etc be done through IR. It'd be more protocol to write, but I can do it. Just not sure if I want the added flexibility of getting data from players as they play the game.

Later Note: The Waspmote is a commercial wireless sensor node based of the ATMega1281, which is arduino compatible. ATMega processors can be used for real, commercial applications. Fun fact to know.

Processor Note: So, I'm using an ATMega328p when I don't need that much functionality. I mean, I need 1 hardware timer, at least 10 I/O pins (if I put a 7-seg LED on it, or other peripherals), and some program space. But switching to an ATTiny could prove prohibitively complicated in the context of an introductory course. I don't want to have people programming an AVR with an arduino just to get a smaller microprocessor. It's a nice thought to use something with less capability because I don't need the capability, but if I end up expanding this project, it'll be nice to have excess program space and I/O pins to play around with. And who knows, maybe I'll need another hardware timer.

Apr 11

Lab 1

This is the first lab assignment in the laser tag course. This lab covers Ohm's Law, LEDs, buttons, breadboarding and schematics. The purpose of this lab is to help you to understand how voltage, current and resistance are interrelated, how to connect circuit elements on a breadboard and how to read schematic drawings.

Before you can build a circuit, you need to know how to connect the parts together. To do this, we are using a solderless breadboard, which is a prototyping tool that is used to connect parts together without permanently bonding them (not using solder, which is a metal that you melt onto wires to connect them). A solder less breadboard has holes in it where you put the wires in to connect them to each other. A picture of a breadboard is shown below to demonstrate how a breadboard is used to connect components together.

Figure 1: Picture of a Breadboard. Every wire is connected only to wires of the same color. (click on the picture to make it bigger)

In Figure 1 above, the wires are connected to all of the wires that are the same color. There are four rails (holes that are electrically connected) that go down the left and right sides of the breadboard. These rails are connected vertically. For example, on the left most rail, all of the red wires are connected to each other and all of the blue wires are connected to each other, but the blue wires are not connected to the red wires. These are usually where you place battery power, with positive voltage on the side of the rail with the red line (this has the red wires in it) and the negative voltage on the rail next to it (this rail has blue wires in it). The middle part of the breadboard has rails that electrically connect the holes horizontally (as the green and yellow wires show). This part of the breadboard is separated into two sections (the green wires are all connected, and they are not connected to the yellow wires). For a true test of connectivity, see if you can explain why all of the grey wires are connected to each other.

The materials that are required to do this lab are: a 9V battery, 9V battery clip, LED (any color), assorted resistors, solder less breadboard, wire, wire strippers (for cutting different lengths of wire). You need to connect the battery, LED, button and resistor on the breadboard so that electricity can flow from the positive terminal of the battery (red wire), through the button, then the LED (through the positive [longer] leg of the LED) to the resistor, and then to ground (negative voltage, or the black wire in Figure 2 below).

Figure 2: Lab 1 Breadboard Picture (click on the picture to make it bigger)


Lab Description:

Build a circuit to turn on an LED using a push button. Calculate the resistor value (how much resistance) that is required to have only 0.02 Amperes (20 mA) go through the LED. The circuit is shown on a breadboard in Figure 2 and the schematic is shown in Figure 3.

Extra Credit:

Find the resistance values you would need for the current consumption to be 5 mA, 10 mA, 15 mA. Build these circuits too and see how the light coming from the LED is effected. Why does this happen?

Apr 09

Lesson 1

In order to tell your arduino how to play laser tag, you are going to need to know how it talks. Arduino's talk using electricity. The purpose of this lesson is to teach the basics of electricity that you will need to build laser tag.

Why learn this?

Two main reasons:

1. Computers communicate using electricity. More specifically, they only understand one thing: whether electricity is present or not. That's it. If we want to talk to our computer, or have it talk to other computers, we are going to have to talk to it in the language it understands (electricity). So, we need to know a little bit about how electricity works in order to talk to the arduino and have the arduino's talk to each other. Arduino's talking to each other is the basis of laser tag.
2. Too much electricity will break the arduino. You need to know how electricity works to keep your arduino from overheating, melting and breaking.


Electricity is tiny particles called electrons that flow through material. It flows more easily in some materials than others. We will be using metal wires to build circuits (more on circuits later), since electrons flow easily through metals (but not as easily through the insulation around the wire, so the electricity won't accidentally flow through something else). There are three factors that determine how much electricity flows through a circuit: voltage, current and resistance.

Voltage measures of how much one thing wants electricity compared to another thing. The higher the voltage, the more the electrons want to flow. One of the best visualizations I know of for electricity is water flowing through pipes. If you imagine a bucket with a pipe in it, the electrons are the water in the bucket. When you lift the bucket off of the ground, water flows out of the pipe. The higher you lift the bucket, more water will come out of the pipe. Similarly, the higher the voltage, the more the electrons want to flow through the circuit (higher electric potential).

Voltage is important because voltage is the only thing that the arduino can understand. The arduino can sense whether voltage is present or not. If you know what the voltage is (or what you want it to be), you can use that knowledge to tell the arduino what to do. Voltage is usually supplied by a battery, and in our case, we are going to regulate the voltage so that we are always working with a voltage that the arduino likes. Voltage is measured in volts, which is represented by the letter V. The voltage that the arduino likes (and that we will use) is 5 Volts, or 5 V.

Current is how many electrons are flowing through a circuit. Going back to the pipe example, current is how much water is flowing through the pipes. Current is important because as electricity flows through something, it heats up. If you have too much current flowing through your arduino, it will overheat, melt and break. Current is measured in amperes. Different electrical devices require different amounts of current, but mostly, our arduino will only want a little bit of current, like 0.02 Amperes, or 0.02 A.

Resistance is how hard it is for electrons to flow through a material. In the pipe example, resistance is how big the pipes are. If you have a really small pipe (or put a kink in the pipe), then less water will flow through the pipe. Resistance is measured in Ohms and is represented by the letter R, and the symbol that represents resistance is the ohm, Ω.

So, putting it all together with the water bucket example. Voltage is how much electricity wants to flow. We can think of that as how high a bucket of water is lifted off of the ground. We will always use a voltage that the arduino likes, which is 5 Volts. Current is how much water flows through a pipe attached to the bottom of the bucket. If there is too much current, your arduino will heat up, melt and break. Resistance is how big the pipe is, which restricts the water and keeps too much from flowing through the pipes. We can put 'kinks' in the pipe to keep too much electricity from flowing through our circuit.

So, how does voltage, current and resistance relate to one another? Georg Ohm figured this out in 1827 and published a paper about it. He called the equation Ohm's Law (he got to name a law of physics after himself because he discovered it), and it states that

 \frac{Voltage}{Current} = Resistance

This means that the voltage through a circuit is equal to the current times the resistance (note, Ohm wrote his equation to read V = IR. V is Voltage, I is current, R is resistance).

That's all the theory that we need to know for laser tag. If you understand electricity, you will be able to keep your arduino happy and control all of the lights, buttons, etc. that we attach to it.


So how do we use Ohm's Law to do useful stuff? The first thing that we are going to do is turn on a light. Light bulbs convert electricity into light. The type of light bulb that we are going to use is called a light emitting diode, or LED for short. An LED is a diode that emits light when electricity flows through it. A diode only lets electricity flow through it in one direction.

We already know that the arduino likes 5 volts, and that we will always set our voltage to 5 volts in laser tag. That means the only two things left to figure out is how much current and resistance we should have to light up our LED. Since current is the thing that damages electronics, we want to make sure there isn't too much flowing through the LED. We can limit the current by putting a resistor in the circuit. Adding a resistor is like adding a kink in the pipe, it keeps electricity from flowing too fast. We will use resistors to limit how much current flows through our circuits and protect our components.

Our LED's are happy with up to about 0.01 amperes of current flowing through them. So what resistance should we use? Looking back at Ohm's law, we know that $latex \frac{Voltage}{Current} = Resistance $ or, written the other way, $latex Resistance = \frac{Voltage}{Current} $. Plugging in that the voltage is 5 and the current is 0.02 (and using a calculator) we learn that:

Resistance = \frac{Voltage}{Current} = \frac{5 Volts}{0.01 Amps} = 500 Ohms

Quick note on resistors. People don't build resistors at exactly the resistance you want. For example, I have a 220 Ohm resistor and a 680 Ohm resistor. If I use a larger resistor, my LED will still work (even though it is bigger than the 500 Ohms of resistance I need). What I don't want to do is use a smaller resistor, which will then have more electricity flow than I want. In this case, we will use a 680 Ohm resistor.

So, how do I use this knowledge to build a circuit? What we need to do is build a path for the electricity to take. It should go through our LED and through our resistor. It doesn't matter which order. If we are using a battery, we need to connect the positive end of the LED to the positive end of the battery, the negative end of the LED to the resistor, and the other side of the resistor to the negative end of the battery. That will make a complete circuit. A complete circuit is a circuit that has a path for the electricity to take from positive voltage to zero voltage (in the bucket example, there is a pipe from the bucket to the ground for water to flow). If we are using a battery, electricity will only flow out of the battery if there is a path from the positive end of the battery to the negative end.

Quick note: electricity will flow through the path of least resistance. When you connect components, make sure that the electricity has to go from positive voltage, through the thing you want to power, through a resistor, and then gets to ground.

But we don't want to have it constantly be on, right? What a waste of energy. Why not put in a button? A button is a momentary switch: it is on (electrically connected) when you push it down and off (electrically disconnected) when you do not push it. To use a button, you put the button in between the battery and the LED. This way, electricity will only flow when you push the button.

Now we need to put all this together and electrically connect it. That's where the breadboard comes in. This is a board with little metal pieces that pinch wires that you put into the holes. This makes it easy to connect wires together. Lab 0 has a little mini-lesson on how to use a breadboard and how to draw your circuit so that other people can make the same thing.

That's everything you need to know to complete lab 0. Now go build something.

Bonus Knowledge
You don't need to know the following to build laser tag. This is extra knowledge if you want to learn more.

Note on units: as you recall, the current that we need to use for the LED is really small (0.02 A). We can use the SI (international system of units) to represent that number as 20 mA (you divide 0.020 A by 1000 to get 20 milliamps, or mA). The SI system has a number of prefixes that you can put in front of the standard unit (in this case, amperes or A), to represent a multiple of ten of that unit. Milli or m, stands for  10^{-3} or \frac{1}{1000} of that unit. If we use mA for current, we have multiplied the current part of Ohm's law ( \frac{Voltage}{Current} = Resistance) by \frac{1}{1000}, so we need to multiply it by 1000 in order to make sure that everything is still equal. The letter k is the SI prefix for 1000, so we can make the equation still hold true by using k Ω for the units of resistance.
If this doesn't make sense to you, don't worry.

I can post more on unit conversions at a later time, since it isn't important for understanding the concepts.

Mar 22

Laser Tag Parts and Resources

Open Source laser tag already exists. Miles Tag is an open source laser tag project that has already developed open source laser tag modules. So why would I reinvent the wheel? I'm not. The purpose of my laser tag project is to teach other people how to build the units themselves and understand the science behind it.

So, here's a link to their tagging protocol. This protocol is the same as Version 2 of my laser tag project. If version 3 (serial) doesn't work, then I'll go back to this method of communication. They also have information about lenses, which is something I haven't looked into yet.

Also, their store has parts and part numbers. I may as well use standard components. Like their IR LED. I probably won't buy these parts from them, since I will most likely be able to get them from mouser, digikey or Jameco for less, but I do appreciate the effort that went into these devices. This is a great resource.