Introduction: DIY Laser Tag System (Microcontroller Verison)
1x 555 timer chip
1x microcontroller (I'm using a Basic Stamp 2 chip but an Arduino would do just as nicely)
4x +/- resistors (1x 330; 1x 2.2K; 1x 4.7k; 1x 22k)
2x +/- photoresistor (1/4" cell with 3 ribs: 2.5M ohm darkness, 3.35k ohm in ambient light, 330 ohm in bright (laser) light)
4x LEDs (probably four different colors would be best and high brightness)
1x tactile switch
various jumper wires
* The resistors are considered to be +/- because the amounts will vary depending on whether you need resistors for the LEDs or if you have fewer or more photoresistors that you want swap in place of the resistors you have.
computer with programming software installed
Step 1: Step 1: Building the Schmitt Trigger, Bells, and Whistles
This step can be broken up into smaller steps so that you can double check your work later on if you get stuck.
Step 1. Connect 555 timer to ground and power (1st and 8th pins respectively)
Step 2. Connect pin6 to ground.
Step 3. Connect a 4.7k resistor from power to pin 2.
Step 4. Connect two photoresistors in series from pin 2 to pin 6.
Step 5. Connect a 330 ohm resistor from the 555 timer output to pin 9 (or other pin of your choice) on the microcontroller.
Step 6. Connect a 2.2k resistor from the 555 timer pin 4 to pin 8 (or other pin of your choice) on the microcontroller.
*your Schmitt Trigger is now done
Step 7. Connect a peizospeaker so that it's ground connects with pin 1 on the 555 timer and a jumper connects its power to pin 6 (or other pin) on the microcontroller.
Step 8. Connect each of your four LEDs so that their anodes go to pins 2 through 5 (or other pins) on the microcontroller and leave open ends on the board. (see image below for details on how it looks)
Step 9. Connect all the cathodes of the LEDs together and connect the last wire of the group to pin 6 (it won't affect the Schmitt Trigger)
Step 10. Connect your tactile switch so that one lead connects directly to pin 0 (or other pin) on the microcontroller, the other lead on the other side connects to power, and the lead one lead on hthe other side connects to ground via a 22k resistor.
Step 11. Finally, if you have a pager motor connect it's positive lead to the 555 timer output directly and ground it directly to the board, for a rumble feature when you're hit.
Step 2: Step 2: Programming = Fun!
This step is just a very short explanation of the programming. First of all, the language used by the Basic Stamp 2 ( you could call it a step brother of the Arduino) is called PBASIC, which you can download for free from Parallax . Keep in mind though, this language is for the Basic Stamp and does not run on other microcontroller (such as the Propeller chip which uses Spin language). Let's have a run-down of the commands necessary for the laser tag counter that I have written:
Hits VAR Nib
The syntax: "Name" "type of data" "data size"
Where "Name" is a user given name to the variable to refer to in programming, "type of data" asks whether the Name is a variable or constant, and "data size" refers to the type of variable it will be: Bit, Nibble, Byte, or Word. A Bit holds a 0 or 1, a Nibble holds numbers 0 - 15, a Byte holds numbers 0 - 255, and a Word holds numbers 0 - 65535.
The syntax: LOW "Pin" : HIGH "Pin"
"Pin" is the pin you want to turn off (LOW) or on (HIGH)
FREQOUT 6, 2000, 1000
The syntax: FREQOUT "Pin", "Duration", "Frequency"
"Pin" is the pin to send a pulse to, "Duration" is how long (in milliseconds) the pulse will last, and "Frequency" is the frequency in hertz.
The syntax: PAUSE "Duration"
"Duration" is the length of pause in milliseconds
FOR Report= 1 TO Total
FREQOUT 6, 100, 2000
The syntax: FOR "Variable"= "Number/Variable" to "Number/Variable"
"Variable" is the name of a variable used for counting, and "Number/Variable" is a number or variable standing in for a starting and ending value for the FOR...NEXT loop to count to before finishing.
IF (Total = 0) THEN ' if no hits, give "error" tone
FREQOUT 6,2000,1000 ' gives speaker "error" tone
The syntax: IF ("Number/Variable" "Operator" "Number/Variable") THEN
"Number/Variable" stands in for a value that should be compared to another value, "Operator" is an operator such as an =, > or <.
And that is all the commands you really need to learn. You can see that these all came from the source code I uploaded below so it has some context and they're not just random examples. I can help with any programming questions that you have, so feel free to drop me a line. Enjoy yourselves and stay tuned for my next circuit using dark triggering.