So the kids got a plastic dart gun at the fair and of course it was broken the next day. What to do? Convert it to a laser gun to do some target practice of course!

It would be easy enough to just throw in a laser, battery and rig the trigger to make contact but then you would be able to shoot non-stop, keep trigger engaged for continuous shooting, etc. Plus, there’d be no sound – how fun is that?

So I went for a small Arduino pro mini I had laying around. This one is a 3.3v 8mhz – plenty for what we need – and it works well off of a 3.7v lipo. The mini will manage the trigger, pulse the laser, make a sound and manage a fake charge/discharge to keep the player on its toes.

  1. The Laser Gun

First step, gut it:

laser gun

Then on to the electronics parts list (for the gun):

  • arduino pro mini 3.3v 8mhz (5v/16mhz will work but you’ll need a different battery). You’ll also need a ftdi-usb adapter to program it.
  • Laser
  • Buzzer
  • (red) led + its resistor
  • I picked a 1S (3.7v) 240mAh because it fits perfectly under the Arduino and inside the gun handle. I get surprisingly good mileage out of it.

That’s it for the gun. I don’t have a wiring diagram but it’s pretty straight forward:

Trigger goes to a digital IN

Laser, LED and buzzer each have their own digital OUT. I use a PWM pin for the LED as it will act as a gauge for available shooting reserve.

I wanted something dead simple to turn it on/off and recharge the battery, so I connected a jtag connector to the battery, GND goes to the mini and the VCC of the mini comes out as a male pin. To charge, just plug the jtag in your charger. To turn on the gun, just plug the pin into the jtag (red wire obviously).

Here’s how it looks like:



And once fitted into the gun:


And we’re done with the gun:



Ah yes, software!

Everything is pretty straight forward: when trigger low is detected, the mini turns the laser on for 200ms and sends a tone to the buzzer.

The only slightly complex thing is the management of a fictitious gauge that replenishes over time. So the more you shoot, the more you empty your “reserve” and time fills it up. If your reserve is empty when you try to shoot, you get a Debbie-downer kind of sound and the laser does not fire.

As mentioned, the red led lights brighter/dimmer with the amount of shooting power you still have and is off when you’re empty. The algorithm for the reserve management is a bit convoluted but the result is pretty good. I actually wrote that a while ago and would be horrified if I had to get into it again.

I also programmed a completely gratuitous and useless boot sequence (GUBS) for when you power the gun. Couldn’t live without it! Oh, and there’s also a cheat code to boot it in infinite mode (bypasses the reserve management altogether but you still have to pull the trigger, you can’t stay on all the time). I ended up telling my kids about the cheat code but not before I beat them silly at the game for a while.

The code is on github, but beware!! it’s dirty and undocumented. There’s also some debugging code still lying around I see.. oh well ;))

  1. The Target

The target will use a LDR to detect the laser, keep score and time and will also make the appropriate hit/win/lose sounds to keep it real.

Parts list:

  • Another Arduino pro mini. This time, it’s a 5v 16mhz. These things are so cheap nowadays!
  • 7-segment display for the score + 2 resistors.
  • LDR + resistor
  • LED + resistor
  • Buzzer
  • On/off switch
  • Lipo 2S (7.4v) 610 mAh

Yes, the 7-seg is supposed to have a resistor for each led. I went the lazy way and only got one for the common ground of each set of pins.

Again, no wiring diagram. The only trick is to get the pins of the 7-seg right. Once you got that, the rest is straight forward.

I went for some free-form soldering and put 4 pins of the 7-seg directly into the Arduino.

3D printed a frame for the LED+LDR and another one for the display. I used small wood plates (that cover one of our everyday goat cheese – so I have plenty of those) and printed “connectors” to  have it stand upright and house the battery, on/off switch, buzzer, etc.

Et voila!





On the software side:

To solder the display directly to the Arduino, I had to use different pins than the usual ones so had to do a wiremap array to redirect to the right pin (instead of rewriting the binary for each digit).

When you turn on the target or before every game, a quick boot sequence signals the start of the game but also takes 50 samples of light on the LDR to use as a baseline since lighting conditions will always vary.

Then, it’s mostly about keeping an eye on millis() to count a minute of gameplay. If you score 10, you win right away, otherwise, it stops after 1 minute and pauses before starting a new game and resetting your score. I also make a beep every 10s as a marker, then a beep every second from 50s to the end of the minute. Makes it more stressful

Source code is available on github.

OVERALL, it’s been great fun. Kids love it. It’s also quite the success when people visit our local fablab: Fuvlab, here’s the link.

Hope someone else will get inspired and go for it!