Arduino Laser Tag - Duino Tag - Instructables.com

23
http://www.instructables.com/id/Duino-Tagger/ Home Sign Up! Browse Community Submit All Art Craft Food Games Green Home Kids Life Music Offbeat Outdoors Pets Photo Ride Science Tech Arduino Laser Tag - Duino Tag by j44 on November 7, 2009 Table of Contents Arduino Laser Tag - Duino Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Intro: Arduino Laser Tag - Duino Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Step 1: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Step 2: Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Step 3: Modding the light gun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Step 4: Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Step 5: Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Step 6: Sound Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Step 7: Visual effects / Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Step 8: The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Step 9: Optional Extras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Step 10: Design Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Step 11: Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Transcript of Arduino Laser Tag - Duino Tag - Instructables.com

http://www.instructables.com/id/Duino-Tagger/

Home   Sign Up!   Browse   Community   Submit

   All     Art     Craft     Food     Games     Green     Home     Kids     Life     Music     Offbeat     Outdoors     Pets     Photo     Ride     Science     Tech

Arduino Laser Tag - Duino Tagby j44 on November 7, 2009

Table of Contents

Arduino Laser Tag - Duino Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro:   Arduino Laser Tag - Duino Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1:   Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 2:   Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 3:   Modding the light gun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 4:   Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 5:   Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 6:   Sound Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 7:   Visual effects / Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Step 8:   The Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Step 9:   Optional Extras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Step 10:   Design Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Step 11:   Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

http://www.instructables.com/id/Duino-Tagger/

Intro:  Arduino Laser Tag - Duino TagDuino tagger- General introduction

Duino tag is a laser tag system based around the arduino.

Finally a laser tag system that can be tweaked modded and hacked until you have the perfect laser tag system for office ordnance, woodland wars and suburbanskirmishes.

Laser tag is combat game like paintball or airsoft without the pain, it uses infrared light (IR) to simulate the tagging / shooting of other players or targets.

I have been working on this project for a while, but don't see it as over, I just though it was time to get more people involved. Hopefully this instructable will be nearenough finished in time for me to enter it in the arduino competition, although I expect the instructable will need editing and tweaking for some time to come. 

This instructable aims to provide you with the information you will need to go out and build your own duino tagger.This instructable focuses on how to build a duino tagger by modifying a light gun but with a bit of extra work you could build you own gun from scratch.

This instructable does not look in too much detail at the software / code side of the project, although a working code based on the miles tag protocol is provided.

For those wishing to learn about duino tagger programming I suggest you start at the excellent tutorials found at A Terrible Idea.

Thoes experience arduino users will probably find the overview page (Step 1) and code pages (Step 8) the most useful, newer arduino users may need to take a closerlook at the instructable and the links provided.

I hope many of you will find this instructable useful and will go on to build your own duino taggers. There is much scope for improving and upgrading this system outlinedhere. If you do go on to improve on this duinotagger please share your work and hopefully in time the system will evolve into a much richer gaming experience.  

Youtube videos of my duino taggers:

This video shows me using the second duino tagger I made to shoot at a talcapult target I have been working on. I hope to make an instructable about the talcapult soon.

Image Notes1. The Mk 2 Duino Tagger2. Arduino & Battery

Image Notes1. Arduino Nano2. Battery3. The Mk 1 Duino Tagger4. Wire to external sensors

http://www.instructables.com/id/Duino-Tagger/

Step 1: OverviewOverview

Key parts of a duino tagger:

IR Transmitter systemWhat - Transistor amplifier, high power IR LED and a lens to give a well focused IR beam.Why - To give the tagger means of tagging / shooting other players as well as communicating game information. The transmitter amplifies the transmission signal fromthe arduino and transmits it using an IR LED, lenses are used to make the signal very directional in order to make the guns behave like guns and make long rangetransmissions possible.

SoundWhat - Peizo Sounder (& mini sound recorder / playback electronics from greetings card)Why - It’s nice to have some audio feedback from the system. Sound effects to let you know when the tagger has been shot or run out of ammunition or lives.

ReceiversWhat - Standard IR receiver module and power regulation capacitorWhy - So the gun knows when it has been shot. This design in this instructable looks at using 3 sensors 1 on the gun as well as front and rear head sensors.

Visual Effects and lightsWhat - LED’s and bar graph driver circuitsWhy - It is nice to get visual feedback on game information, eg lights to let you know when you have been shot. 

CostTo make this section internationally friendly; at the time of writing: £1 GBP = $ 1.6 USD = 1.1 EUR

Assuming you already own an arduino the basic extra components for this project can be bought for around  £10.

Now is a great time to try to build a duino tagger as it is easy to get hold of cheap second hand light guns. Light guns are the guns that you can use with computer games,many of them don’t work with modern LCD screens and so there are a lot of them going cheap on ebay and else where. I bought two light guns each cost about £4 oneoff ebay one from a charity shop. Light guns are a great starting point for this project as they provide the optics, switches and case required for the build.

You will need:

ArduinoLight GunColoured LED’s (preferably 30mA+)IR sensorsAt least 2x IR LED’s matched to the IR receiver  (preferably 100mA+)Peizo sounderPower transistor /MOSFETA few electronics basics: solder, resistors , capacitors.

You may also wantScrap plasticLED bar graph driver chipsMore LED’sRecord your own message greetings cardHats / helmets / headbands to mount sensors on

Image Notes1. Arduino Duemilanove2. 9v battery (pp3)3. LED's Show ammo level4. Switches5. Trigger switch

http://www.instructables.com/id/Duino-Tagger/

6. Sound: Piezo Sounder7. Transmitter IR LED transmitter and two red LEDs for muzzle flare.8. Transmitter amplifier: Transistor and a few resistors covered in electrical tape.9. Optics10. Wire to head sensors11. Receiver12. Rumble / Force feedback motor. Not used (battery could not cope).

Step 2: BasicsBasics

Page to try to help the electronics noobs.

Some basics which are useful at several points in the design of the duino tagger.

R = ResistorC = CapacitorV = VoltageI = Current

Using LED'sLED's must be used with a resistor to limit the current through them.Choose the current the LED will work atR = (V supply - V led) / INot: You will probably just be able to copy the resistor values I used.

ButtonsThe buttons (triggers etc) in this project are assumed to give a low voltage when pressed. The standard circuit for this is show in the circuit diagram provided. 

FiltersR C (Resistor Capacitor) circuits can come in useful at a few places in duino tagger, either for smoothing out changes in the power supply voltage or to turn PWM signalsinto analogue levels, not as complicated as it might sound:

To use the water analogy for electricity and current the resistor acts like a narrow pipe (imagine a straw) only allowing slow water (current) flow. The capacitor acts like abig water tank / bucket. The low pass filter in the diagram acts like a straw and bucket combo: Even if you suddenly change the flow of water in or out of the bucket thelevel (voltage) will only change slowly.

Cut off frequency for low pass: f = 1/(2pi*R*C)

http://www.instructables.com/id/Duino-Tagger/

http://www.instructables.com/id/Duino-Tagger/

Step 3: Modding the light gun

Modding the light gun

The details of the light gun modifications will depend on the light gun.Here are some general guidelines and ideas:

Useful parts to leave in the:SwitchesTriggerLED'sLense

Adding storage space to your light gun: Fitting things in can be difficult, you might also not wish to put your arduino inside the gun. I wanted to be able to easily removemy arduinos from my duino taggers so I could use them in other projects.On one of my duino taggers (MK1 gun) I cut holes in the case for the arduino nano pins to go through and mounted a socket on the inside of the gun so the arduinoplugged on the outside of the gun. On my Mk2 gun I added an external case for the arduino and tried to make it look like an ammunition clip. The case / ammo clip wasmade from plastic I got from a cheap ring binder folder and its cover is held in place by a strong magnet.

http://www.instructables.com/id/Duino-Tagger/

Step 4: TransmitterIR transmitter

You will need:IR LED: Look for an LED with a narrow viewing angle (to ensure as much of the IR light makes it through the optics).Higher power the better.Pick LED’s with a wavelength that matches your IR receivers.Get some spare LED’s as they are operated above their rated current so may burn out.

You can just attach an IR LED (with a current limiting resistor) to an output pin on the arduino and it will be able transmit, but the range of the duino tagger won’t be veryimpressive. In order to improve the range of the duino tagger amplification is needed.

The basic amplifier I made was a simple transistor circuit (circuit diagram provided), you may wish to consider a mosfet instead of the transistor.

Current through the LED: I aimed for about 300mA current through the IR LED. This is more than the rated current for the LED, but the LED seems to be able to copebecause you are only pulsing the high current for a short time. If you are using the 5V supply from the arduino to power the LED it can only provide about 400/500mA sousing 300mA for the IR transmitter Led does not leave too much for the other LED’s and speakers etc, so bare this in mind when designing building your duino tagger, itmight be a good idea to add a voltage regulator capable of supplying higher currents.

Optics

You will need to use a lense to focus the IR beam, you can use the lense that came with the light gun. You can use a red LED to work out where to put the IR led to get agood focused beam.For more details see the miles tag site.

Image Notes1. Lense2. Transmitter and muzzle flare LED's

Step 5: ReceiverReceivers

The receivers are for detecting when the tagger has been shot and receiving game data.

The receivers are standard IR remote control receivers like you would find in a TV remote.

There are quite a few different receivers you can choose from I went for the cheapest I could find the main things to consider are:

Will you be able to find a matching LED, one that works at the same light wavelength that the sensor is optimised for, If you don't match the LED and receiver the taggerrange will be reduced.

If you want to be able to use your duino tagger to be compatible with any other duino tag, laser tag or miles tag systems you will need be working at the same modulationfrequency and light wavelength.

Most of the IR receivers work in a very similar way and you will be able to wire then up the same as the circuit diagrams in the pictures.

The output pin of the receiver drops to a low voltage when a signal is being received. The outputs from multiple sensor can be connected and one sensor receiving willstill cause the combined output signal voltage to drop.

The receivers work on there own and can be connected directly to the arduino, but they are much more reliable when used with capacitors to regulate the power supplyand pull up resistors.

http://www.instructables.com/id/Duino-Tagger/

http://www.instructables.com/id/Duino-Tagger/

Step 6: Sound EffectsAudio / Sound Effects

Adding sounds to the system makes for a better game experience. It is nice to have sounds for the:

Fire, been shot, start, dead / out of lives sound, out of ammo..........

Ideally to add sounds you would use a fully featured audio shield like the wave shield.keep me updated if you try this.

For simplicity and to save on build cost I chose just to use a piezo buzzer, this works well for most of the system tones, but it is tricky to use the piezo to make a good gunshot noise.If you are interested in the details of making sounds on an arduino usining a piezo buzzer have a look at the melody example.

One simple and cheap way of adding better sound effects to your duinotagger is to use the electronics form a “record your own message” card.  You can get the cardsfor £2/3 off ebay.Mini instructable.1.    Remove the electronics from the greetings card.2.    Play around with the electronics for a while to get an idea for what it all does.3.    The card circuit will play the recorded sound as soon as it is powered. The card circuit draws about 50mA so can be powered direct from an arduino output, ideallyyou would power it at 3V to the card circuit (the same as the button cells that powered it previously), but I did not encounter any problems powering it with the 5v directform the arduino. If you found that 5v was damaging the circuit you could diodes to reduce the voltage (just make sure you pick ones able to cope with 50mA). 

http://www.instructables.com/id/Duino-Tagger/

4.    Connect the arduino output to where the positive on the batteries originally powering the circuit would have been and connect the arduino ground to where thebattery negative was. You should now find when the arduino output goes high the sound recorded on the card circuit is played.

Methods of recording the sound to the card circuit, you could just use the microphone (peizo transducer) that came with it or for slightly better sound quality you could usea potential divider (eg 10k pot) to connect it up to a computer and record directly to the circuit.

You may wish to consider adding an audio amplifier to make the sound effects a bit more impressive.

Step 7: Visual effects / Lighting

Display / Visual Feedback

It is nice to have visual feedback for things like ammunition and lives there are a few ways you could do this: the main being using LED’s or an LCD to display theinformation.

I chose to uses LED’s, and there is provision for using LED’s in the code provided.The code varies two of the arduino’s PWM pins( ammoPin and lifePin) dependant on the  ammunition and life.

The PWM pins can be used to power LEDs and the more life or ammo the player has the brighter the LEDs will be alternatively the PWM output can be used to drive anbar graph driver chip like the LM3914NThe PWM output can not be used to directly drive a bar graph driver chip, the PWM signal needs to be smoothed to give an analogue output, this can easily be doneusing an RC low pass filter.

Step 8: The CodeThe Code

Code Notes:I am not going to go into much detail about how the code works hopefully the fairly extensive comments provided in the code will be enough to explain it, if not the thereare already good tutorials out there.

Limitations:The code only works is set up in a way that it can only do one thing at a time and until the dual core arduino is easiest just to cope with that.This means when one tagger is shooting it will not notice if it gets shot/tagged.  You could complicate the code by using interrupts , but in the real world it is not really abig problem, the shooting or getting shot happen so quickly that they very rarely interfere with each other.In future iterations of the code I will probably make it so that the tagger checks to see if it has been tagged in-between each bit it transmits, making it very very unlikelythat it would miss an incoming message (hit / tag). I have played a few games using this code and similar code and it seems to work well.

------------------------------------------------------------------------------------------------------------------

//      Start of code (copy and paste into arduino sketch)////                       Duino Tag release V1.01//          Laser Tag for the arduino based on the Miles Tag Protocol.//           By J44industries:     www.J44industries.blogspot.com// For information on building your own Duino Tagger go to: http://www.instructables.com/member/j44///// Much credit deserves to go to Duane O'Brien if it had not been for the excellent Duino Tag tutorials he wrote I would have never been able to write this code.// Duane's tutorials are highly recommended reading in order to gain a better understanding of the arduino and IR communication. See his sitehttp://aterribleidea.com/duino-tag-resources///// This code sets out the basics for arduino based laser tag system and tries to stick to the miles tag protocol where possible.// Miles Tag details: http://www.lasertagparts.com/mtdesign.htm// There is much scope for expanding the capabilities of this system, and hopefully the game will continue to evolve for some time to come.// Licence: Attribution Share Alike: Give credit where credit is due, but you can do what you like with the code.// If you have code improvements or additions please go to http://duinotag.blogspot.com//

// Digital IO'sint triggerPin             = 3;      // Push button for primary fire. Low = pressedint trigger2Pin            = 13;     // Push button for secondary fire. Low = pressedint speakerPin             = 4;      // Direct output to piezo sounder/speakerint audioPin               = 9;      // Audio Trigger. Can be used to set off sounds recorded in the kind of electronics you can get in greetings card that play a custom message.

http://www.instructables.com/id/Duino-Tagger/

int lifePin                = 6;      // An analogue output (PWM) level corresponds to remaining life. Use PWM pin: 3,5,6,9,10 or 11. Can be used to drive LED bar graphs. egLM3914Nint ammoPin                = 5;      // An analogue output (PWM) level corresponds to remaining ammunition. Use PWM pin: 3,5,6,9,10 or 11.int hitPin                 = 7;      // LED output pin used to indicate when the player has been hit.int IRtransmitPin          = 2;      // Primary fire mode IR transmitter pin: Use pins 2,4,7,8,12 or 13. DO NOT USE PWM pins!! More info:http://j44industries.blogspot.com/2009/09/arduino-frequency-generation.html#moreint IRtransmit2Pin         = 8;      // Secondary fire mode IR transmitter pin:  Use pins 2,4,7,8,12 or 13. DO NOT USE PWM pins!!int IRreceivePin           = 12;     // The pin that incoming IR signals are read fromint IRreceive2Pin          = 11;     // Allows for checking external sensors are attached as well as distinguishing between sensor locations (eg spotting head shots)// Minimum gun requirements: trigger, receiver, IR led, hit LED.

// Player and Game detailsint myTeamID               = 1;      // 1-7 (0 = system message)int myPlayerID             = 5;      // Player IDint myGameID               = 0;      // Interprited by configureGane subroutine; allows for quick change of game types.int myWeaponID             = 0;      // Deffined by gameType and configureGame subroutine.int myWeaponHP             = 0;      // Deffined by gameType and configureGame subroutine.int maxAmmo                = 0;      // Deffined by gameType and configureGame subroutine.int maxLife                = 0;      // Deffined by gameType and configureGame subroutine.int automatic              = 0;      // Deffined by gameType and configureGame subroutine. Automatic fire 0 = Semi Auto, 1 = Fully Auto.int automatic2             = 0;      // Deffined by gameType and configureGame subroutine. Secondary fire auto?

//Incoming signal Detailsint received[18];                    // Received data: received[0] = which sensor, received[1] - [17] byte1 byte2 parity (Miles Tag structure)int check                  = 0;      // Variable used in parity checking

// Statsint ammo                   = 0;      // Current ammunitionint life                   = 0;      // Current life

// Code Variablesint timeOut                = 0;      // Deffined in frequencyCalculations (IRpulse + 50)int FIRE                   = 0;      // 0 = don't fire, 1 = Primary Fire, 2 = Secondary Fireint TR                     = 0;      // Trigger Readingint LTR                    = 0;      // Last Trigger Readingint T2R                    = 0;      // Trigger 2 Reading (For secondary fire)int LT2R                   = 0;      // Last Trigger 2 Reading (For secondary fire)

// Signal Propertiesint IRpulse                = 600;    // Basic pulse duration of 600uS MilesTag standard 4*IRpulse for header bit, 2*IRpulse for 1, 1*IRpulse for 0.int IRfrequency            = 38;     // Frequency in kHz Standard values are: 38kHz, 40kHz. Choose dependant on your receiver characteristicsint IRt                    = 0;      // LED on time to give correct transmission frequency, calculated in setup.int IRpulses               = 0;      // Number of oscillations needed to make a full IRpulse, calculated in setup.int header                 = 4;      // Header lenght in pulses. 4 = Miles tag standardint maxSPS                 = 10;     // Maximum Shots Per Seconds. Not yet used.int TBS                    = 0;      // Time between shots. Not yet used.

// Transmission dataint byte1[8];                        // String for storing byte1 of the data which gets transmitted when the player fires.int byte2[8];                        // String for storing byte1 of the data which gets transmitted when the player fires.int myParity               = 0;      // String for storing parity of the data which gets transmitted when the player fires.

// Received dataint memory                 = 10;     // Number of signals to be recorded: Allows for the game data to be reviewed after the game, no provision for transmitting / accessing it yetthough.int hitNo                  = 0;      // Hit number// Byte1int player[10];                      // Array must be as large as memoryint team[10];                        // Array must be as large as memory// Byte2int weapon[10];                      // Array must be as large as memoryint hp[10];                          // Array must be as large as memoryint parity[10];                      // Array must be as large as memory

void setup() {  // Serial coms set up to help with debugging.  Serial.begin(9600);                Serial.println("Startup...");  // Pin declarations  pinMode(triggerPin, INPUT);  pinMode(trigger2Pin, INPUT);  pinMode(speakerPin, OUTPUT);  pinMode(audioPin, OUTPUT);  pinMode(lifePin, OUTPUT);  pinMode(ammoPin, OUTPUT);  pinMode(hitPin, OUTPUT);  pinMode(IRtransmitPin, OUTPUT);  pinMode(IRtransmit2Pin, OUTPUT);  pinMode(IRreceivePin, INPUT);  pinMode(IRreceive2Pin, INPUT);   frequencyCalculations();   // Calculates pulse lengths etc for desired frequency  configureGame();           // Look up and configure game details

http://www.instructables.com/id/Duino-Tagger/

  tagCode();                 // Based on game details etc works out the data that will be transmitted when a shot is fired    digitalWrite(triggerPin, HIGH);      // Not really needed if your circuit has the correct pull up resistors already but doesn't harm  digitalWrite(trigger2Pin, HIGH);     // Not really needed if your circuit has the correct pull up resistors already but doesn't harm   for (int i = 1;i < 254;i++) { // Loop plays start up noise    analogWrite(ammoPin, i);    playTone((3000-9*i), 2);  }    // Next 4 lines initialise the display LEDs  analogWrite(ammoPin, ((int) ammo));  analogWrite(lifePin, ((int) life));  lifeDisplay();  ammoDisplay();

  Serial.println("Ready....");}

// Main loop most of the code is in the sub routinesvoid loop(){  receiveIR();  if(FIRE != 0){    shoot();    ammoDisplay();  }  triggers();}

// SUB ROUTINES

void ammoDisplay() { // Updates Ammo LED output  float ammoF;  ammoF = (260/maxAmmo) * ammo;  if(ammoF <= 0){ammoF = 0;}  if(ammoF > 255){ammoF = 255;}  analogWrite(ammoPin, ((int) ammoF));}

void lifeDisplay() { // Updates Ammo LED output  float lifeF;  lifeF = (260/maxLife) * life;  if(lifeF <= 0){lifeF = 0;}  if(lifeF > 255){lifeF = 255;}  analogWrite(lifePin, ((int) lifeF));} 

void receiveIR() { // Void checks for an incoming signal and decodes it if it sees one.  int error = 0;   if(digitalRead(IRreceivePin) == LOW){    // If the receive pin is low a signal is being received.    digitalWrite(hitPin,HIGH);    if(digitalRead(IRreceive2Pin) == LOW){ // Is the incoming signal being received by the head sensors?      received[0] = 1;    }    else{      received[0] = 0;    }       while(digitalRead(IRreceivePin) == LOW){    }    for(int i = 1; i <= 17; i++) {                        // Repeats several times to make sure the whole signal has been received      received[i] = pulseIn(IRreceivePin, LOW, timeOut);  // pulseIn command waits for a pulse and then records its duration in microseconds.    }       Serial.print("sensor: ");                            // Prints if it was a head shot or not.    Serial.print(received[0]);     Serial.print("...");       for(int i = 1; i <= 17; i++) {  // Looks at each one of the received pulses      int receivedTemp[18];      receivedTemp[i] = 2;      if(received[i] > (IRpulse - 200) &&  received[i] < (IRpulse + 200)) {receivedTemp[i] = 0;}                      // Works out from the pulse length if it was a data 1 or 0 that wasreceived writes result to receivedTemp string      if(received[i] > (IRpulse + IRpulse - 200) &&  received[i] < (IRpulse + IRpulse + 200)) {receivedTemp[i] = 1;}  // Works out from the pulse length if it was a data 1 or 0that was received        received[i] = 3;                   // Wipes raw received data      received[i] = receivedTemp[i];     // Inputs interpreted data     

http://www.instructables.com/id/Duino-Tagger/

      Serial.print(" ");      Serial.print(received[i]);         // Print interpreted data results    }    Serial.println("");                  // New line to tidy up printed results       // Parity Check. Was the data received a valid signal?    check = 0;    for(int i = 1; i <= 16; i++) {      if(received[i] == 1){check = check + 1;}      if(received[i] == 2){error = 1;}    }    // Serial.println(check);    check = check >> 0 & B1;    // Serial.println(check);    if(check != received[17]){error = 1;}    if(error == 0){Serial.println("Valid Signal");}    else{Serial.println("ERROR");}    if(error == 0){interpritReceived();}    digitalWrite(hitPin,LOW);  }}

void interpritReceived(){  // After a message has been received by the ReceiveIR subroutine this subroutine decidedes how it should react to the data  if(hitNo == memory){hitNo = 0;} // hitNo sorts out where the data should be stored if statement means old data gets overwritten if too much is received  team[hitNo] = 0;  player[hitNo] = 0;  weapon[hitNo] = 0;  hp[hitNo] = 0;  // Next few lines Effectivly converts the binary data into decimal  // Im sure there must be a much more efficient way of doing this  if(received[1] == 1){team[hitNo] = team[hitNo] + 4;}  if(received[2] == 1){team[hitNo] = team[hitNo] + 2;}  if(received[3] == 1){team[hitNo] = team[hitNo] + 1;} 

  if(received[4] == 1){player[hitNo] = player[hitNo] + 16;}  if(received[5] == 1){player[hitNo] = player[hitNo] + 8;}  if(received[6] == 1){player[hitNo] = player[hitNo] + 4;}  if(received[7] == 1){player[hitNo] = player[hitNo] + 2;}  if(received[8] == 1){player[hitNo] = player[hitNo] + 1;}     if(received[9] == 1){weapon[hitNo] = weapon[hitNo] + 4;}  if(received[10] == 1){weapon[hitNo] = weapon[hitNo] + 2;}  if(received[11] == 1){weapon[hitNo] = weapon[hitNo] + 1;} 

  if(received[12] == 1){hp[hitNo] = hp[hitNo] + 16;}  if(received[13] == 1){hp[hitNo] = hp[hitNo] + 8;}  if(received[14] == 1){hp[hitNo] = hp[hitNo] + 4;}  if(received[15] == 1){hp[hitNo] = hp[hitNo] + 2;}  if(received[16] == 1){hp[hitNo] = hp[hitNo] + 1;}     parity[hitNo] = received[17];

  Serial.print("Hit No: ");  Serial.print(hitNo);  Serial.print("  Player: ");  Serial.print(player[hitNo]);  Serial.print("  Team: ");  Serial.print(team[hitNo]);  Serial.print("  Weapon: ");  Serial.print(weapon[hitNo]);  Serial.print("  HP: ");  Serial.print(hp[hitNo]);  Serial.print("  Parity: ");  Serial.println(parity[hitNo]);    //This is probably where more code should be added to expand the game capabilities at the moment the code just checks that the received data was not a systemmessage and deducts a life if it wasn't.  if (player[hitNo] != 0){hit();}  hitNo++ ;}

void shoot() {  if(FIRE == 1){ // Has the trigger been pressed?    Serial.println("FIRE 1");    sendPulse(IRtransmitPin, 4); // Transmit Header pulse, send pulse subroutine deals with the details    delayMicroseconds(IRpulse);     for(int i = 0; i < 8; i++) { // Transmit Byte1      if(byte1[i] == 1){        sendPulse(IRtransmitPin, 1);        //Serial.print("1 ");

http://www.instructables.com/id/Duino-Tagger/

      }      //else{Serial.print("0 ");}      sendPulse(IRtransmitPin, 1);      delayMicroseconds(IRpulse);    }

    for(int i = 0; i < 8; i++) { // Transmit Byte2      if(byte2[i] == 1){        sendPulse(IRtransmitPin, 1);       // Serial.print("1 ");      }      //else{Serial.print("0 ");}      sendPulse(IRtransmitPin, 1);      delayMicroseconds(IRpulse);    }        if(myParity == 1){ // Parity      sendPulse(IRtransmitPin, 1);    }    sendPulse(IRtransmitPin, 1);    delayMicroseconds(IRpulse);    Serial.println("");    Serial.println("DONE 1");  }

  if(FIRE == 2){ // Where a secondary fire mode would be added    Serial.println("FIRE 2");    sendPulse(IRtransmitPin, 4); // Header    Serial.println("DONE 2");  }FIRE = 0;ammo = ammo - 1;}

void sendPulse(int pin, int length){ // importing variables like this allows for secondary fire modes etc.// This void genertates the carrier frequency for the information to be transmitted  int i = 0;  int o = 0;  while( i < length ){    i++;    while( o < IRpulses ){      o++;      digitalWrite(pin, HIGH);      delayMicroseconds(IRt);      digitalWrite(pin, LOW);      delayMicroseconds(IRt);    }  }}

void triggers() { // Checks to see if the triggers have been presses  LTR = TR;       // Records previous state. Primary fire  LT2R = T2R;     // Records previous state. Secondary fire  TR = digitalRead(triggerPin);      // Looks up current trigger button state  T2R = digitalRead(trigger2Pin);    // Looks up current trigger button state  // Code looks for changes in trigger state to give it a semi automatic shooting behaviour  if(TR != LTR && TR == LOW){    FIRE = 1;  }  if(T2R != LT2R && T2R == LOW){    FIRE = 2;  }  if(TR == LOW && automatic == 1){    FIRE = 1;  }  if(T2R == LOW && automatic2 == 1){    FIRE = 2;  }  if(FIRE == 1 || FIRE == 2){    if(ammo < 1){FIRE = 0; noAmmo();}    if(life < 1){FIRE = 0; dead();}    // Fire rate code to be added here    } }

void configureGame() { // Where the game characteristics are stored, allows several game types to be recorded and you only have to change one variable (myGameID)to pick the game.  if(myGameID == 0){    myWeaponID = 1;    maxAmmo = 30;

http://www.instructables.com/id/Duino-Tagger/

    ammo = 30;    maxLife = 3;    life = 3;    myWeaponHP = 1;  }  if(myGameID == 1){    myWeaponID = 1;    maxAmmo = 100;    ammo = 100;    maxLife = 10;    life = 10;    myWeaponHP = 2;  }}

void frequencyCalculations() { // Works out all the timings needed to give the correct carrier frequency for the IR signal  IRt = (int) (500/IRfrequency);    IRpulses = (int) (IRpulse / (2*IRt));  IRt = IRt - 4;  // Why -4 I hear you cry. It allows for the time taken for commands to be executed.  // More info: http://j44industries.blogspot.com/2009/09/arduino-frequency-generation.html#more

  Serial.print("Oscilation time period /2: ");  Serial.println(IRt);  Serial.print("Pulses: ");  Serial.println(IRpulses);  timeOut = IRpulse + 50; // Adding 50 to the expected pulse time gives a little margin for error on the pulse read time out value}

void tagCode() { // Works out what the players tagger code (the code that is transmitted when they shoot) is  byte1[0] = myTeamID >> 2 & B1;  byte1[1] = myTeamID >> 1 & B1;  byte1[2] = myTeamID >> 0 & B1;

  byte1[3] = myPlayerID >> 4 & B1;  byte1[4] = myPlayerID >> 3 & B1;  byte1[5] = myPlayerID >> 2 & B1;  byte1[6] = myPlayerID >> 1 & B1;  byte1[7] = myPlayerID >> 0 & B1;

  byte2[0] = myWeaponID >> 2 & B1;  byte2[1] = myWeaponID >> 1 & B1;  byte2[2] = myWeaponID >> 0 & B1;

  byte2[3] = myWeaponHP >> 4 & B1;  byte2[4] = myWeaponHP >> 3 & B1;  byte2[5] = myWeaponHP >> 2 & B1;  byte2[6] = myWeaponHP >> 1 & B1;  byte2[7] = myWeaponHP >> 0 & B1;

  myParity = 0;  for (int i=0; i<8; i++) {   if(byte1[i] == 1){myParity = myParity + 1;}   if(byte2[i] == 1){myParity = myParity + 1;}   myParity = myParity >> 0 & B1;  }

  // Next few lines print the full tagger code.  Serial.print("Byte1: ");  Serial.print(byte1[0]);  Serial.print(byte1[1]);  Serial.print(byte1[2]);  Serial.print(byte1[3]);  Serial.print(byte1[4]);  Serial.print(byte1[5]);  Serial.print(byte1[6]);  Serial.print(byte1[7]);  Serial.println();

  Serial.print("Byte2: ");  Serial.print(byte2[0]);  Serial.print(byte2[1]);  Serial.print(byte2[2]);  Serial.print(byte2[3]);  Serial.print(byte2[4]);  Serial.print(byte2[5]);  Serial.print(byte2[6]);  Serial.print(byte2[7]);  Serial.println();

  Serial.print("Parity: ");  Serial.print(myParity);

http://www.instructables.com/id/Duino-Tagger/

  Serial.println();}

void playTone(int tone, int duration) { // A sub routine for playing tones like the standard arduino melody example  for (long i = 0; i < duration * 1000L; i += tone * 2) {    digitalWrite(speakerPin, HIGH);    delayMicroseconds(tone);    digitalWrite(speakerPin, LOW);    delayMicroseconds(tone);  }}

void dead() { // void determines what the tagger does when it is out of lives  // Makes a few noises and flashes some lights  for (int i = 1;i < 254;i++) {    analogWrite(ammoPin, i);    playTone((1000+9*i), 2);  }   analogWrite(ammoPin, ((int) ammo));  analogWrite(lifePin, ((int) life));  Serial.println("DEAD");   for (int i=0; i<10; i++) {   analogWrite(ammoPin, 255);   digitalWrite(hitPin,HIGH);   delay (500);   analogWrite(ammoPin, 0);   digitalWrite(hitPin,LOW);   delay (500);  }}

void noAmmo() { // Make some noise and flash some lights when out of ammo  digitalWrite(hitPin,HIGH);  playTone(500, 100);  playTone(1000, 100);  digitalWrite(hitPin,LOW);}

void hit() { // Make some noise and flash some lights when you get shot  digitalWrite(hitPin,HIGH);  life = life - hp[hitNo];  Serial.print("Life: ");  Serial.println(life);  playTone(500, 500);  if(life <= 0){dead();}  digitalWrite(hitPin,LOW);  lifeDisplay();}

Step 9: Optional ExtrasOther features

There is a lot of potential for the game to be improved the code I have provided transmits quite a lot of data when shooting another tagger. This leaves the potential forplayer statistics at the end of the game, different weapon types etc...

Force feedbackMany light guns come with an eccentrically weighted motor to give force feedback, on one of the duino taggers I made I wired this up to allow for force feedback, but itcaused a lot of problems as the pp3 9v battery I was using could not really cope with the power demands. So only attempt to add force feedback if you have a decentbattery pack.

Secondary fire:I have started to write some provision for this into the code.

Compatibility:I have tried to make the code fairly compatible with the MilesTag Protocol, the chances are it will be able to transmit and receive the data, although the code does not yethave much provision for acting on the information.

http://www.instructables.com/id/Duino-Tagger/

Step 10: Design IdeasI have been thinking about building a duino tagger from scratch. Here are a few of the concept sketches I drew of gun design ideas. Hopefully they might offer some ideasand inspiration. 

Image Notes1. Steampunk tagger Made from bits of pipe etc

Step 11: Links

My Sites:

j44industries

Laser tag and Duino tag:

Duino Tag Code Tutorials

Miles Tag the DIY laser tag system

Arduino Links:

Melody

Button

Related Instructables

Explosion Effect- Talcapult byj44

Ninja tag bybowmaster

lazer tag at theKalahari! bythekid

Paintball, Howit's done.BeginnersGuide by dkfa

Zombie Tag bybendog38

ScenarioPaintball bycaptocommando

http://www.instructables.com/id/Duino-Tagger/

Comments

50 comments Add Comment view all 54 comments

 williamanos says:  Feb 26, 2011. 6:42 AM  REPLYIf I wanted to do this with all hardware could I not just put a PNP transistor on the output of the IR detector and connect lights/sounds etc to power throughthe PNP transistor?

Thanks!Will

 williamanos says:  Feb 25, 2011. 7:11 PM  REPLYAre the receivers interfered with by sunlight? Can it be used on a sunny day with lots of direct sunlight?

 Nate711 says:  Nov 14, 2010. 8:39 PM  REPLYj44 the first receiver picture is hard to read because of its low quality. Could you upload a better picture? the rest is clear and awesome. the tactapult is alsoneat

 j44 says:  Nov 15, 2010. 2:13 PM  REPLYFeedback appreciated.

Have done what I can within the resolution and compression limits on the web site. Hope its ok now, if not I will have a think about what else I can do (Iwould probably have to upload the picture as several smaller parts).

 Nate711 says:  Nov 15, 2010. 6:15 PM  REPLYI just discovered that I can click on the picture info button and get a high quality picture. I feel dumb. thanks anyways

 green laser pointer says:  Nov 2, 2010. 2:25 AM  REPLYI think you can try the laser sight for your gun or rifle that provided by http://www.greenlaserpointer.org

 KT Gadget says:  Nov 17, 2009. 6:32 PM  REPLYThis is awesome! I am just about to use the Arduinos for a competition my robotics club is going into. I really want to build a full on laser tag system for mygroup of friends to mess around with.

One question though, wouldnt a laser work the same way (i know the hazard might be the problem) but isnt that what is used for most laser tag systems?

As a suggestion, make a simple voltage regulator for the arduino and add a bigger battery to be able to use the motor, but I am not sure how to signal themotor to move (Im thinking using a PWM system?).

 j44 says:  Nov 18, 2009. 12:36 PM  REPLYThanks!

All laser tag systems that I know of use IR diodes, although some systems have a low power laser as well just to show where you have shot. If you wereto just use a laser then you would find the bean would be far too narrow; you would either have to coat the players head to toe in sensors or aim veryvery accurately at the sensors, I think you would struggle to get a realistic game feel.

I have got force feedback motors working with the arduino, but I wanted to keep these guns small and relativly simple so didn't want to bother with abigger battery pack so disabled the feature.

Let me know how you get on.

 sparktech says:  Sep 4, 2010. 3:57 PM  REPLYhey i was wondering i dont know if you can do this but heres my idea could you tell me how i could do this? ok so a small screen to tell you where theother people are (10 ft acurate) a umpc built into the gun so at the beginning of the game you choose a gun (machine gun, sniper rifle, etc. each gunhas dif. ammo quantities, damage, and "range") each person gets a pistol with unlimited ammo. get 3 grenades,1 nuke (each has dif radius of howmuch it kills) 100 health to start with and all the sensors are on the gun (maybe 6?) i was wondering if you could get and program all these things intothe gun i dont care about costs so could you just tell me how or if you think it is possible? i am learning how to program this stuff but i have about 6people who could help me program the arduino Thanks

http://www.instructables.com/id/Duino-Tagger/

 j44 says:  Sep 5, 2010. 2:44 PM  REPLYDifferent types of guns etc would be quite easy to implement, I started to put support for that in the code. Knowing where other players are wouldprobably need GPS, wireless links and screens etc, to start from scratch would be tricky and expensive. If I were to undertake a build like that Iwould think about using the arduino with an android phone. The android phone would provide the GPS, screen and wireless communication, in asmall convenient easy to program device. For how to use an arduino with an android phone try looking at the amarino tool kit:http://www.amarino-toolkit.net/ Let me know if you build anything, would be interested to see any pics or vids.

 sparktech says:  Sep 5, 2010. 6:33 PM  REPLYhttp://www.sparkfun.com/commerce/product_info.php?products_id=8977 this is even easier than the other touchscreen this would not be aproblem to put on the arduino

 sparktech says:  Sep 5, 2010. 6:31 PM  REPLYhere is a screen and a trackball to use as a button so you could select stuff and scrollhttp://www.sparkfun.com/commerce/product_info.php?products_id=8537http://www.sparkfun.com/commerce/product_info.php?products_id=9320 then if price is not an option you could use this and substitute it forboth or keep the trackball (i love the blackberry trackballs) http://www.sparkfun.com/commerce/product_info.php?products_id=8624 pleasetell me what you think about this

 sparktech says:  Sep 5, 2010. 5:42 PM  REPLYsure ill let you know what i do!!

 sparktech says:  Sep 5, 2010. 5:41 PM  REPLYfor gps couldnt you use an xbee module? they make screens for arduino

 j44 says:  Nov 15, 2010. 2:29 PM  REPLYIts taken me longer than I am proud of to notice what seems to be going on here.

Its almost you have a vested interest in advertising SparkFun products :-)

So I will say the following:

I have recently used the MP3 Trigger V2 to add sound to a project and it was great (easy to use and worked very well).http://www.sparkfun.com/commerce/product_info.php?products_id=9715Would be a great way of improving the sound effect on a duino tagger.

I have also had very good experiences with several arduino pro minis recently.http://www.sparkfun.com/commerce/product_info.php?products_id=9218Great for any compact duino tag projects.

So credit where credit is due I have had good experience with SparkFun products.

Still think it would be cool to have a duino tagger android app ;-P

 Kryptonite says:  Nov 19, 2009. 9:46 PM  REPLYIn Canberra where I am, we have a laser tag arena that we often to go for birthday parties (not so much now...) where you get a vest with sensors onthe shoulders, front, back and on the gun. If you should just off the sensor, then it will not sound it. But if the laser points directly at it then you'regood. This does not make it much harder at all.

This arena also has "bases" which you have to shoot 3 times (with 3 second down time between each shot at the base) and then you capture it andscore 10 points in stead of 1.

Feedback motors are cool, but as a "laser" feel it's alright if they're kept off, to keep with the futuristic feel of just the laser.

 Jaderman says:  May 7, 2010. 11:14 AM  REPLYHey, great instructables! Got a question though. I've been looking over the internet for a light gun and I can't seem to find one anywhere. Is there a site thatyou know of or a link you could send me that has one for sale? Thanks 

 sparktech says:  Sep 4, 2010. 10:27 PM  REPLYhey also try to make one out of whatever you have!!! (wood, plexiglass, lexan, stuf like that) make your body then make a frame and put them togetherdepending on what you want it to look like personally myself i like one from the fifth element that im going to try and rebuild here is a picturehttp://www.zorgltd.co.uk/images/photos/ZF-1_500x340.jpg i think i might take all the missiles and stuff in the front out and replace them for sensors andmore circuitry bet you get the concept! have fun

 sparktech says:  Sep 4, 2010. 3:50 PM  REPLYhey jaderman, Use any nerf gun that you think looks cool and can fit all the electronics just buy the gun and gut it (springs, gears, posts, etc.) with adremel. Hapy building!

http://www.instructables.com/id/Duino-Tagger/

 emmanuel.smith says:  May 13, 2010. 7:24 AM  REPLY I can't find them either. Does anyone know how to turn an airsoft gun into a light gun or is there an instructable on it?

 j44 says:  May 13, 2010. 2:11 PM  REPLYIn the UK if you type "Light Gun Playstation 2" or "Light Gun PS2" into an Ebay search there are plenty of results.

You might have more luck searching for the brand names and models eg:NamcoG-ConLogi-3Joytech

 blueberrypieisgood says:  Dec 3, 2009. 1:44 PM  REPLYi just have a litle question. with the IR leds spreading all around, and to get the beam to a narrow range, how can you do this? is it the lens? would a convexlens do the trick? or what?

 sparktech says:  Sep 4, 2010. 3:52 PM  REPLYget a double convex lense

 pewepintheformats says:  Apr 27, 2010. 4:19 AM  REPLY What model of transistor would you reccomend for the transmitter?

 j44 says:  May 2, 2010. 11:52 AM  REPLYI used a BC337G which seems to work well. The important points are to make sure the transistor is NPN type and can cope with the high power, itshould be able to handle at least 300mA. 

Hope that helps

 benip90 says:  Apr 6, 2010. 4:50 PM  REPLYthis is awsome, i wanna make my shock tag guns more open and fun as a free for all, atm its in teams and only has the one sensor on the chest i want it soyou can mutiny at any point or team fire as well as the team mode with out a reset, with some form of "clip" with its own memory and two 7 segment displaytwo show a two digit clip size. any help? could a aurdino mini handle all that?

 on4tux says:  Mar 4, 2010. 12:21 PM  REPLYI would like to take it a step further: what if we can combine this with gps and data exchanging? Then you can play this in the woods, hunting each other withbeeps if you come closer. Agreed, you would need a HAM radio license for long distances, but I think it is possible to do some half duplex data exchange viaPMR radios

 amando96 says:  Mar 4, 2010. 2:10 PM  REPLY that's where xbee, comes in.

 ronmaggi says:  Nov 23, 2009. 7:49 PM  REPLY would a laser and reciever from an old cd player give any decent range?

 steveastrouk says:  Dec 5, 2009. 11:11 AM  REPLYCD diodes are IR diodes, not visible, so they won't help you aim.

I did it with visible ( class II) laser diodes about 16 years ago for a commercial system - we had no problems with hitting people, and it was more realisticthan the blunderbuss IR systems. You really had to aim !

Beam size was about 1" at 30 feet from memory.

Steve

 j44 says:  Nov 30, 2009. 2:45 PM  REPLYThis project uses IR diodes not actual lasers.

If you were to use lasers you would likely get a good range, but probably only 3/4 mm tolerance with lining up the laser and sensor so it would beextremely hard to soot the other player. It may also be necessary to ware eye protection if you try to use lasers.

IR is better suited for this project and is what the commercial systems use.

http://www.instructables.com/id/Duino-Tagger/

 uberben says:  Nov 29, 2009. 3:15 PM  REPLY I am curious why you included the diode in the first receiver schematic. As far as I can tell, leaving out the diode and making that connection open would dothe exact same thing except that only one line on the arduino will go low for each cluster of sensors instead of both lines going low when the gun gets hit.Removing the diode would reduce cost and complexity, unless I am missing something.

Also, I am curious why the resistor in the second schematic of the receivers is connected between the GND and output pins of the sensor when in the firstschematic it is connected between +5 and output. Connecting to +5 makes the most sense if it is intended as a pull-up resistor.

 j44 says:  Nov 30, 2009. 2:38 PM  REPLYGood questions.

The diode - The reason I have designed it like that is so that no matter which sensors gets hit you will always be able to decode the signal from the mainreceiver pin; this simplifies and speeds up the code a bit. It also has the advantage that if the incoming signal can move from being read by either set ofsensors and will still be correctly decoded (i.e. the first part of the signal is received by the head sensors and the second half by the gun sensor). Thereason I didn't just put all the sensors directly onto one input as being able to tell where the player has been shot has the potential to make the gamemore interesting (more points for a head shot etc).

Resistor on the second diagram - well spotted that is a mistake it should be a pull up resistor between the 5v and output, I will try to correct that soon.

Glad to see people taking a close look at the plans and I hope that answers your questions.

 uberben says:  Nov 30, 2009. 3:26 PM  REPLYOkay, that makes sense. I haven't looked at your code yet as I intend to write my own pretty much from the ground up and won't be doing that forsome time yet, but I will have to see how you are handling the hit sensors. On a side note, it is kind of hard to follow the code when posted into thingslike blog posts or Instructables. It might be worth while looking into using something like github.com as it makes sharing code (as well as versiontracking) much nicer and allows people to fork your code directly as well as merge any changes you make with their respective branches. At the veryleast, to make it easier to follow I would suggest using some sort of "code tag" in your blog post so that it is more readable and retains all of itsindentation. You could use something like this for your blogspot blog, I think.

Having said that, great work with all of this. I look forward to seeing more of your work, especially the laser dogfight system.

 fishgish509 says:  Nov 21, 2009. 2:49 PM  REPLYi voted

 j44 says:  Nov 30, 2009. 2:45 PM  REPLYThanks!

 roychook says:  Nov 28, 2009. 7:48 PM  REPLYwhat lenses did you have to use to make the beam of infrared light more focused and go longer

 duncan_a says:  Nov 19, 2009. 4:14 AM  REPLYHave you taken a look at the Battlefield Sports S*A*T*R system?

I recently 'converted' 60+ guns from their old classic version to the new one (board and sensor swaps plus RF feedback) and it got me thinking aboutdeveloping an Arduino-based multi-purpose 'bomb' device.

I'm not a programming type techie and have no idea of their IR protocols but it does appear to be a 38Khz system...

Any thoughts?

Duncan

 j44 says:  Nov 21, 2009. 6:37 AM  REPLYI have not seen the Battlefield Sports S*A*T*R system before, but it looks very similar to ones I have seen before.

Bomb / grenade taggers would be an interesting addition. It shold be fairly easy to build one.

The first step would be to confirm it works at 38kHz and find out the light frequency the taggers work best with. The easiest way to do this would be tolook for part numbers on the back of the IR receiver modules.On each of sensors on the player there will be several of the receivers, they are the little black square components (see picture attatched).Then google the part number and read the specs, it will tell you the optimum frequencies.

It would be best to find out the protocols (it is probably very similar to the miles tag protocol that I use), although this is unlikely to be easy. There areways arround the problem though; it would be quite easy to build bomb which would record a signal and play it back when activated, so the player wouldhave to shoot the bomb, the bomb would then record their code and play it back when it "explodes".

I might be able to help a bit with the code, but I make no promisses.

Keep me informed

J44

http://www.instructables.com/id/Duino-Tagger/

 DemonSpawn says:  Nov 19, 2009. 8:03 AM  REPLY what do you do with the wire that comes out of the gun?how about makeing a belt that that wire conects to witch provides power maby.or mount evey thing on the belt and put only the detector ect in the gun therfor you can make compact guns.

 Kryptonite says:  Nov 19, 2009. 9:34 PM  REPLYIt goes to a head piece / body piece with sensors. And no it doesn't really spread much.

 sturific says:  Nov 19, 2009. 8:14 PM  REPLYgood idea will have to add sound to irritate the neighbors.

 DemonSpawn says:  Nov 19, 2009. 9:36 AM  REPLY also do you have to hit the target exactly or does the ir beam spread abit?

 Jestersage says:  Nov 15, 2009. 1:45 AM  REPLYWow! You also beat me by the long shot. I was still studying O'Brian's code to get it working as a MilesTag with interupt. Anyway, one idea I think work betteris to swap the receiving and the shooting section (which is soemthign I tried with O'Brian's code), since if you are shot, your gun is not likely to work in reallike.

 MrLouque says:  Nov 14, 2009. 8:35 AM  REPLY sweet instructable!!! If its in the arduino contest I will vote for it

 j44 says:  Nov 14, 2009. 1:24 PM  REPLYThanks!

I have entered the instructable in the arduino contest so really appreciate any good ratings or votes when voting opens.

 microman171 says:  Nov 13, 2009. 10:56 PM  REPLYThe only thing stopping me from building a full featured open source laser tag system:  Lenses.

Where did you get your lens from?

I have plans to use the ATmega48, some form of LCD screen (maybe 8x2 char, or 16x2), and some DIY bodies.

 j44 says:  Nov 14, 2009. 3:46 AM  REPLYIn the two taggers that this instructable looks at they use the lenses that came with the light guns.

For better lenses try:http://www.surplusshed.com/

I found some good lenses in magnifying glasses from a local stationary shop, although I got some odd looks when using an led torch to test their focallengths.

I considered using an LCD display, but decided to try and keep this a simple and cheap project just to get something working, and perhaps be a bit moreambitious next time around.

http://www.instructables.com/id/Duino-Tagger/

 microman171 says:  Nov 14, 2009. 12:46 PM  REPLYThanks for the link!

They have exactly what I am looking for!

I looked around all sorts of shops with no luck finding the right lens.  I don't want to have a 200mm magnifying lens on a pistol etc...

You could also use shift registers and some LED displays.  It is possible two IO pins to drive 12 seven segment displays.  The 74HC595 is a serial in,parallel out.  You send serial data to the chip, and it is converted to highs and lows on the output pins!

I'll be sure tog et a few soon =)

Good luck with the tagger.  It really is a great project!

 Stephen D. Alverez says:  Nov 13, 2009. 3:33 PM  REPLYIs that actually shooting something, or is it just telling a pre-made smoke bomb to blow up, because if its shooting, its damn cool!

view all 54 comments