This idea came into life when i was working on some promotional thing for scouting.
The idea was: wouldn't it be fun for the kids to have something to shoot with and to shoot at.
The first idea was to make some sort of ping pong ball canon, aimed at some cans. But that would mean i needed a vacuum cleaner.. and considering i wanted 3 of those, the idea was quickly abandoned.
As an alternative, i checked my parts drawers and came across enough stuff to make 3 laser guns with.
It kindof spiralled out of control from there.. ending up in a nice project!
So, after some drawing and designing, i came up with this idea:
We will have 3 guns, with a laser in it. It should have a limited amount of shots, and should be able to count the hits. For that, it has to have some sort of display.
It is also nice if some sort of sound is produced. It doesn't have to be hifi, some bleeps will do.
No wires will be attached to the guns, so nobody can accidentally damage a gun by breaking those. This means the gun has to operate on batteries.
Each gun will have it's own target, which should be able to move. Each gun will have it's own dedicated target, so no difficult encoding scheme is needed.
The guns should have a finite amount of shots, easily reloadable and the gun should be easy to clear for the next player.
First of all, we are working with a laser. So some protection is needed for the eyes. The glasses for lasers depend on the light that is transmitted.
To make absolutely sure no accidents can happen, we will need those for the players and the person running the game.
Also, as an added security, the gun will not send out a steady beam of light, but will pulse the laser with each shot.
Each pulse will be no more than 50ms, which is within safety limits of indirect exposure.
In NO WAY anybody should look straight into a laser, even if it's pulsed!
Last, when using the game, care should be taken that no reflection can come off the targets nor from anything surrounding the targets to anywhere.
So check if there are any reflective surfaces behind the targets!!
The parts i pulled together for each gun:
The circuit i built:
- 1 industrial laser (= a laser in a metal housing of 5mW plus a lens in front. They are a nice package)
- 1 rfid reader (RFC522) with some rfid tokens (in my version: 4 round ones and 3 cards)
- 1 active piezo buzzer
- 1 4 digit display (the same TM1637 ones as used in the joti project)
- 1 arduino nano 5 volt version
- 1 HC-12 422mhz tranceiver
- 1 BC547B transistor
- 1 10k resistor
- 3 AA batteries
- 1 external holder for 3 AA batteries with a cover and switch
- some flatcable to connect it all
- some cheap plastic guns from a toystore
(click on the image for a larger version)
The guns i got a hold of are simple things, small sized (kindof looking like colt M4) models that don't even have screws to hold them together.
The most important part is: it has to have space for all the parts in it (except batteries) and has to have some sort of working trigger mechanism. It doesnt matter what it does, as long as it can be used as a trigger.
The trigger mechanism is gutted so a microswitch can be installed, making the trigger press the switch while sliding past it, so the switch doesn't become the 'endstop' of the trigger.
It might be needed to alter the trigger itself a little, but this is entirely up to the creativity of yourself.
I liked keeping the trigger instead of just installing a switch because the gun looks like a gun still and a microswitch has less 'bounce'.
The batteries are in a seperate battery box, which i hotglued against the 'magazine', feeding the wires through a hole drilled straight through the housing and gun so no wires are exposed.
It sort of looks like one of those extra large magazines used with airsoft guns
Once done, the gun can be glued or tie-wrapped shut, so nobody can open it and tamper with the electronics (remember, there is a laser in it..).
I did remove any led's on the arduino and other electronics to save on power, so the gun should last at least a day on 3 AA batteries..
After all is done, here are the guns i made (the ruler is for reference on the size of them, click on the images to get a large view):
As you can see, the display is tucked away behind the trigger mechanism, the rfid reader is stuck ontop of it.
I used hotglue to stick everything in place so it won't move around or rattle when handling the guns.
The most important thing in the code would be the time sensitive pulse for the laser. It can in no way exceed the 50ms. So in the code, that is simply done by switching it on, waiting with a delay for 50ms and then switch it off again.
So it does interrupt everything else, but since it is only 50ms, it won't interfere to much. Besides, when a shot is fired, nothing else has to be done anyway.
Everything else, can be done 'in good time', since it is not time sensitive. Even the bleeps aren't because i used an active piezo.
These just need a plus and minus to beep so all that needs to be done is switch the port high, and switch the port low again in due time.
The rfid's are used to 'load' the gun and to reset it. For this, it's easiest to scan the rfid's, dump the id's to the serial and use the value.
Then assign each rfid to whatever function is needed.
In my case, i have 4 keychain models, and 3 cards.
The 4 keychain models, i assigned as such:
Since the display can only handle a maximum of 99 shots, that's the maximum shots that the gun will accept when adding shots.
- 1 - clear/reset the gun
- 2 - add 25 shots
- 3 - add 50 shots
- 4 - add 99 shots
The cards i assigned as:
When the gun is cleared, all the functions switched on with a card are switched off.
- A 'double tap' card. It will flash the laser twice with each shot. This is nice to have in bright environments.
- A full auto card. The gun will keep firing until either the shots are depleted or the trigger is released. It negates the double flash option.
- A test card. The card will switch to full auto, but will not decrease the shots counter. Hits are registered.
All the card functions are switch on/off type, meaning: with each scan it will switch on and then off the corresponding function.
The hits are received from the controller module using the HC-12 modules. At first the gun will look for a ! sign, then followed by a gun number. If that is the number of this gun, then it will beep and add a hit.
For future purposes, it also scans for a + sign, followed by a byte denoting how many shots should be added. This could be used for remotely adding shots just like using the rfid's on the gun.
The entire code for the guns can be downloaded here: Lasergun code
When uploading to the guns, please note that each gun has its own number! This number is set in ascii code, so a 1 is actually 49. Find the line "#define GUNNUMBER" and change it to the correct value.
So: gun 1 = 49, gun 2 = 50, etc.
A target is simple: it has to detect when a laser hits the right spot and then report that hit back to the gun and move to another posision (yes, i want them to move!)
The way i constructed the targets is to use a simple LDR with an arduino.
Since i don't want any wires to the gun, the hits are reported wireless to them using a HC-12 tranceiver unit.
And here comes trouble: when all targets have their own transmitter, collisions can occur. There are numerous ways around this with protocols, but i wanted to keep things simple...
Also, each unit has to get power somehow, preferably delivered from 1 source.
So instead of having a transmitter on each target, i made a central unit that will have the transmitter and supplies the power to each target.
For this, i went for UTP! Any UTP cable can handle power and signals (they do it with POE already in networks..).
The specs for what is allowed are more than enough for this project. Also, you can pick up UTP cables in various lengths, ready made, at any computer shop..
The UTP cable has 8 wires, which are used as:
Combining 2 wires should be enough to handle the power of the servo, the arduino power is negligable compared to the servo.
- 1 + 2 = +5V
- 3 = hit signal
- 7 + 8 = GND
The hit signal is simple: pulling it low signals a hit.
The targets are now simple setups using:
- 1 arduino (nano, 5 volt version)
- 1 servo (5 volt). I went for a MG559, since they have high torque (10kg) and have ball bearings, which should make them last a very long time!
- 1 LDR resistor
- 1 10K resistor
- 2 switches or 2 pin jumpers
- some aluminium corner lengths, tubes and flat bar
- flat black paint
There are 2 jumpers in the circuit. The function for these:
- 'RUN' jumper - when connected, the arduino gets it's power from the main power supply. But when programming, it's best to disconnect it so the arduino is powered by the USB plug.
- 'TEST' jumper - normally connected, it will allow the arm to take a random position. If disconnected, it will only move left to right to the most extreme positions. This mainly is used when setting things up with multiple targets to make sure the arms do not overlap.
I put the arduino and RJ45 jack on a piece of experimental board (or hole board) adding some headers so the servo can be connected using the plug that is on it.
Also, i made the 'RUN jumper' and the 'TEST jumper' a 2 pin header with a jumper on it instead of a switch.
The central unit is made using:
Each of the RJ45 has power connected as stated, but each of the jacks has wire 3 connected to a different port on the arduino.
- 1 arduino
- 3 RJ45 jacks
- 1 HC-12 module
- 1 USB cable
- 1 USB charger that can deliver at least 2A
This way, the arduino can tell what target has been hit, and can send the correct gun that signal.
So it makes no difference to the targets what gun they belong to, it is dictated by the port the UTP cable is plugged in to.
The entire schema for the central unit and the targets:
(click on the image for a larger version)
The target unit (on the right) gets it's power from the RJ45 plug, so no special power plug or leads are needed at the target.
The central unit can be powered by attaching a USB charger to the red (+5V) and black (GND) leads.
For the targets I put everything on a 60 X 40mm experimental board for easy installation on the target:
The controller unit i used a larger board (70 x 85mm) to put everything on so it's easy to add to:
For some extra fastening i hotglued the RJ45 ports to the board and added some extra on the sides.
The code for the targets themselves is pretty straightforward:
- the target moves to a position at random.
- once there, the LDR is read to determine the ambient light at that time and position and the hit signal line is pulled high
- the target stays at that position until a hit is registered
- if hit, the signal is given to the cental unit by pulling the signal line low
- the whole loop is started over from the top.
The cental unit code also is fairly simple:
- check each known target port if it is low
- for each low port, send a hit to the gun belonging to that port number using the HC12 transmitter
Some things aren't used in my setup but is in the code for the controller:
I leave it up to you to do something with this. In this setup, it's all ignored, all targets are on all the time.
- I added a 'learn mode'. The standard is that each target has its own gun (target 1 = gun 1, etc). By adding a button to pin 8, and a LED (with 1k resistor!) to port 9, you can switch the controller in learning mode.
It will send out a signal to the guns telling them this state. If you fire the gun at any target, this will become the designated target of that gun, overwriting the default.
- There is a possibility to either enable or disable a target by using a switch on ports 2,3 and 4. If pulled low, this will disable target 1,2 or 3 resp.
- There is a posibility to send a signal to something else by attaching it to ports A0, A1 and A2 (for target 1,2 or 3 resp). They will be pulled high if a hit occurred and the target isn't switched off.
All the code can be downloaded here:
Since there are still 3 wires left, there is ample room for expansion, even employing i2c on it (by changing the wiring a little to each RJ45 jack).
In the code for the targets 2 extra ports are reserved: port 3 for signaling to the target to be active or not and port A1 for another LDR sensor.
If port 3 is high, the target will be inactive and will stop all function. If the line is pulled low, the target will be active.
The second sensor port is read, but nothing is done with that value, since no LDR is attached to it so far.
The code for the central unit has ports reserved for sending the active signal to the targets plus inputs for switches, but neither are used so far in the actual code.
The code uses a couple of libraries for the hardware used:
Around here, you can get aluminium corner lengths of 1 meter at the local home improvement shop (gamma, karwei, hornbach, etc).
They are 10mm high and wide and the wall thickness is around 1.5 mm.
Also available is aluminium tubing with a diameter of 10mm and 10mm wide strips.
The hinge is constructed by 3d printing it.. This has to be able to come apart easy so the swingarm is detacheable from the stand and can be easily stored in a box.
The download links for printing the hinge can be found at the bottom of this block.
The way things are set up, the maximum swing at the top is just about the same as the length of the arm!
For each target, as i made them, the parts list is:
- 3d printed parts
- 1 baseplate
- 1 servo cap
- 1 top part (with or without the circuitboard holder)
- 1 coupler piece
- 2 pins
- 2 pinlocks
- 1 servo (MG995)
- 1 meter corner length
- 10 cm tube
- 20 cm flat strip
- 2 M3 X 10 bolts with nut
- 1 M3 X 15 bolt with 2 nuts
- the circuit board with the target electronics on it. Mine are 60 X 40mm
How the hinge fits together can be seen on the pictures:
Remarks on this design:
- The aluminium is press-fitted in the upper hinge part. Put the it in a vice and gently tap the upper part on it with a hammer. It should go in about 5 cm. Do NOT hit the rounded parts (the hinge bits), they will break if you do.
- There are 2 versions of the upper part of the hinge. One is just the part, the other one has a circuit holder attached to it for a circuit board size of 60mm wide. Just one version is needed.
- Make sure to print the upper hinge part upright!! It takes a LOT more support, but there can't be any support in the slot where the aluminium goes in to, you will never get any supports out of there!
- It is stable and solid enough to handle the load, even with the servo at full speed, so no need to have ramp ups etc.
- It comes apart easy using 2 self-locking pins
- The pins have a lock built in. The easiest way to put together the pin is to use a vice and press the small pinlock in the slot over the nudges, or print it in place.
- The size of the pin is intentionally just a bit to large.
- No extra parts needed except 1 M3 bolt for connecting the coupler to the servo arm. First secure the bolt with a nut to the arm of the servo, then put the coupler on and last another nut, locked in with loctite.
- Take care connecting the servo!! If you put the plug wrong on the headers, it will blow up the arduino. For this purpose, a small 'O' is printed on the holder, denoting which side the Orange wire goes.
When putthing things together, make sure you lock the outer nut on the servo arm with loctite so it won't come off, and press the cap above the servo holder on it so it fixes the servo in place with the tabs in the slots top and bottom.
The servo is put in upright with the axle at the top.
To prevent any reflection coming back to the shooter, everything is painted in flat black.
To finish things off, it's fun to put something over the targets/ldr tube. For this some cardboard with a funny face, bullseye or something else on it is painted.
A hole is made for the ldr tube and then it's attached to the arm.
Whatever you do, make sure it's not adding too much weight to the top of the arm.
The finished target assembly:
Yes, the target is balanced so that if it stands upright, it can stand on its own! Ofcourse not when it goes to either side, that is where the holes come in, they can be used to fasten this hinge to a stand.
I didn't do any after-printing finishing at all, it should just fit together and work, with two exceptions: the pin and the pinlock.
The pinlock fits kinda snug, so it's nice if you sand the sides down a bit. After fitting it to the pin, it should not be that loose so it rotates on its own, but you shouldn't need pliers to rotate it.
Also, after installing the pinlock, use some sandpaper to sand the entire pin. The pin fits tight and is intended to be sanded down.
Sand it down just enough so it will fit snug but it isn't hard to place or remove. This will also make the pinlock flush to the pin.
The picture doesn't show a stand because i don't have one. I made a crude one out of some wood, lifting the target about 25cm off the floor, setting the target at about 1.25m high.
Once i made a (foldable!!!) stand, i will add it to this page.
All the files for printing the hinge parts: