Mod your Nerf gun with a Pi

Michael Darby, who blogs at 314reactor, has created a new Raspberry Pi build, and it’s pretty darn cool. Though it’s not the first Raspberry Pi-modded Nerf gun we’ve seen, it’s definitely one of the most complex!

Nerf Gun Ammo Counter / Range Finder – Raspberry Pi

An ammo counter and range finder made from a Raspberry Pi for a Nerf Gun.

Nerf guns

Nerf guns are toy dart guns that have been on the market since the early 1990s. They are popular with kids and adults who enjoy playing paintball, laser tag, and first-person shooter video games. Michael loves Nerf guns, and he wanted to give his toy a sci-fi overhaul, making it look and function more like a gun that an avatar might use in Half-Life, Quake, or Doom.

Modding a Nerf gun

A busy and creative member of the Raspberry Pi community, Michael has previously delighted us with his Windows 98 wristwatch. Now, he has upgraded his Nerf gun with a rangefinder and an ammo counter by adding a Pi, a Pimoroni Rainbow HAT, and some sensors.

Setting up a rangefinder was straightforward. Michael fixed an ultrasonic distance sensor pointing in the direction of the gun’s barrel. Live information about how far away he is from his target is shown on the Rainbow HAT’s alphanumeric display.

View of Michael Darby's nerf gun range finder

To create an ammo counter, Michael had to follow a more circuitous route. Since he couldn’t think of a way to read out how many darts are in the Nerf gun’s magazine, he ended up counting how many darts have been shot instead. This data is collected via a proximity sensor, a device that can measure shorter distances than an ultrasonic sensor. Michael aimed the sensor towards the end of the barrel, attaching it with Blu-Tack.

View of Michael Darby's nerf gun proximity sensor

The number of shots left in the magazine is indicated by the seven LEDs above the Rainbow HAT’s alphanumeric display. The countdown works for more than seven darts, thanks to colour coding: the LEDs count down first in red, then in orange, and finally in green.

In a Python script running on the Pi, Michael has included a default number of shots per magazine. When he changes a magazine, he uses one of the HAT’s buttons as a ‘Reload’ button, resetting the counter. He has also set up the HAT so that the number of available shots can be entered manually instead.

Nerf gun modding tutorial

On Michael’s blog you will find a thorough step-by-step guide to how he created this build. He has also included his code, and links to all the components, software installation guides, and test scripts he has used. So head on over there if you’re keen to mod your own nerf gun like this, and take a look at some of his other projects while you’re there!

Michael welcomes suggestions for how to improve upon his mods, especially for how to count shots in a magazine automatically. Do you have an idea? Let usand himknow in the comments!

Toy mods

Over the years, we’ve covered quite a few fun toy upgrades, and some that may have to be approached with caution. The Pi-powered busy board for babies, the ‘weaponized’ teddy bear, and the inevitable smart Fisher Price phone are just a few from our archives.

What’s your favourite childhood toy, and how could it be improved by the addition of a Pi? Share your ideas with us in the comments below.

1 comment

Avatar

I had already considered the concept of an ammo counter and I came up with a few reasonable solutions (or at least as reasonable as they can be for the subject) that should work well enough but require different implementations. Both require modifying the magazines themselves internally and adding connection points inside the gun but then from those points you could route externally to a Pi or other devices mounted on the outside of the gun.

Option one is essentially a whole row of switches down the inside of the magazine. One continuous electrical rail going down the inside and one rail per position the follower rests in for each remaining shot. As the follower slides into each position you have essentially closed a switch and which one has a closed circuit tells you the position of the follower and thus how many shots are remaining above it. Concept wise it is very simple to implement and for smaller magazines it could just use the GPIO pins or a cheap I2C chip or two. The obvious downside is that for every single shot a magazine holds you need an extra line. This isn’t a big deal if you only want to use a 5 shot magazine as that would only necessitate 6 lines total but with 10 lines internal routing could get tricky even with copper tape and with 15 rounds you are not only hitting the limits of most reasonably priced I2C hardware the internal routing might drive you nuts with trying to avoid accidental shorts. Past 15 rounds or with the drum magazines it isn’t really a feasible thing to even try. The biggest downside is have all the individual contact points for the magazine to touch when inserted into the gun so that the Pi or other device can actually read all the positions. The biggest advantage of this design is that it is so simple electrically that you don’t need any computing power at all technically. You could just have the counter be a row of LEDs with numbers next to them.

Option two would require FAR fewer connections but would require some programming and reading an analog value AND depending on the parts used you would essentially have to calibrate the first time you used a magazine. There are flexible materials often used in the fingers of data gloves and other devices. You could have one mounted below the follower and use the reading from how far it is bent at the position for each shot to read how much ammo was remaining. The extra complexity would be that each magazine would need a way to identify itself to the gun because of variances in parts and magazine sizes necessitating different calibrated input ranges to be read for each shot number. Input wise it would be almost like reading a steering wheel since it would be a single analog input. This might let you reuse some existing code intended for reading controller inputs. I believe if insulated and mounted to a guide of some sort it could curl up like a watch spring and thus be usable in one of the drum magazines.

Option three (which I just realized while writing all of this) might require the fewest parts of all three options but also might be the priciest and could require visible external modification of the magazines. As far as I can figure it would also be completely incompatible with the drum magazines. Place a sensor in/at the bottom of the magazine and aim it up at the bottom of the follower. Read the distance from the sensor to the bottom of the follower and calculate the shot number based on the range. But as I said, the sensors might be too bulky to fit in the magazine and would require cutting a hole in the bottom. Consideration would also have to be given to the housing of the sensor mounted thus to prevent somebody from accidentally knocking it off or accidentally smashing it when inserting a magazine.

There is an option four but it only applies to the belt fed Vulcan. Install a RFID reader in the gun and a tag to each dart holder on the belt. This is of course crazy, but then so is the very idea of a belt fed battery operated fully automatic dart gun.

Leave a Comment

Comments are closed