I built this Nerf Sentry Gun by grafting a couple of Arduinos, a power supply, a motor, and an ultrasonic distance sensor onto a Nerf Vulcan machine gun. I posted these build notes on Make: online. I’ve never compiled them all in one place, however, so this post serves to tie the whole project together in one place.
Part 1: Wiring the trigger
The first step was to add wiring and a two-wire connector to control the trigger circuit. I opened up the Nerf Vulcan (about 30 screws) and soldered an 1/8″ female jack to the fire selection mode switch. This way, I can retain all the regular functions of the gun when it’s unplugged from the Arduino. To control it from the Arduino, I’ll flip the orange switch on top to “off” and then wire the trigger into the “pulled” position (done here with a classy twist tie). Whenever the Arduino’s trigger circuit closes (bypassing that orange “off” switch) the gun will start firing.
To add the connector, I drilled a 1/4″ hole in the gun’s hand grip, fed the sleeve through, and secured it with a couple of zip ties inside for strain relief.
Next, I’m planning to build the Arduino’s trigger circuit using a MOSFET transistor wired to a male 1/8″ jack I can plug into the gun.
Part 2: Relay firing circuit
Now, I need a circuit to fire the gun from the Arduino microcontroller by bridging the two wires coming from the 1/8″ jack I put in the handle. I’m doing this is with a small, 5V relay wired to a digital pin and ground of the Arduino (my original plan called for a MOSFET, but the spot I wired to made a relay easier). Relays are electro-magnetic switches that can be opened and closed by energizing their coils. In this case, the low current, 5V from the Arduino is enough to do the trick all by itself. Here’s a snazzier circuit, if you have a less Arduino-friendly relay. My circuit also has a diode in it to prevent the collapsing magnetic field from frying the board. Here’s my sketch of this:
Here it is on a breadboard. I loaded a simple blink sketch on the Arduino, so that it pauses for four seconds, then fires the gun for one second, repeats. This is great for testing, and means I can now command a barrage of Nerf darts from my microcontroller. Watch out!
Part 3: Soldering the relay circuit
The next step in making my autonomous Arduino Nerf sentry gun is to move the relay circuit from the temporary breadboard onto something more durable and permanent, yet easy to connect. Wires from the Arduino and the trigger switch jack will need to connect through the relay board.
I soldered the relay, diode and some screw terminal connectors onto a piece of perfboard. I connected the appropriate leads using small bits of wire I’d snipped off of some LEDs for a previous project. One hilarious/awful bit of troubleshooting I had to do was due to a hidden connection between every three pads on my original perfboard. Once I realized what was going on, I re-soldered things onto a more appropriate board.
Finally, I wired up the relay coil terminals to open and close from a timed test sketch on an Arduino. When the coils were energized, my multimeter beeped to indicate the closing of the switch. This is exactly what will need to happen to fire the Nerf gun.
Part 4: Motorized mount
What’s a Nerf sentry gun without a sweeping rotation? I knew I needed motorized rotation to cover a wide field of (foam) fire, but how to mount the thing?
I disassembled the supplied tripod mount and found my answer: there was a spring loaded mount that clamped to the underside of the Nerf gun.
I went in search for a surplus DC gear motor that could be adapted to the mount clamp, and found a 250 RPM 12V motor with a plastic disc attached to its shaft. I marked and drilled some holes in the disc to screw the mount clamp into. Now I’m ready to build a stand to attach the motor to and bear the weight of the entire sentry gun. There’s no way the plastic toy tripod it came with is up to the task, so I’m checking out some t-slot aluminum instead.
Part 5: Making the stand
Once I’d attached the Nerf gun to the motor mount, I designed a stand to support the gun and the distance sensor, Arduinos, and firing circuit. Using some 20mm 80/20 t-slot aluminum and connectors, I built this. It started out as a tripod, but grew some feet, so now I’m not sure what to call it.
I didn’t have a profile long enough to add support to the angled front and back pieces, so I grabbed a piece of scrap from the stereo I removed from my wife’s car and used that.
The motor that sweeps the gun back and forth is driven by a MotorShield and Arduino. To know when to reverse direction, I added a bump switch to either side of the stand framing. When the grip hits a switch, it’ll go the other way. In a marriage of two competing aluminum building systems, I’ve got MicroRaxplates coupling the switches to the 80/20.
Here it is in it’s full glory. The aluminum is strong, but lightweight. Once the electronics are complete, and enclosed, I’ll attach them to the stand as well.
Part 6: Primary Arduino enclosure
Next up in my Arduino Nerf sentry gun build, enclosures for the electronics. I’m using two Arduino microcontrollers, and each one has a shield and set ofScrewShields for wiring. I decided to use two Arduinos because the 7-Segment shield and MotorShield each consume a lot of pins. It would be possible to reroute some of those and adjust the libraries and code, but I’m running out of time. I’m bringing this project to Maker Faire next weekend, and I’d rather avoid explaining things to the TSA, so it needs to be in a box for shipping pretty soon!
I’ll post a full system diagram soon, but here’s the quick version: Primary Arduino reads PING))) sensor distance data, drives the 7-Segment shield for display, triggers the relay firing circuit, and sends commands to the secondary Arduino. The secondary Arduino drives the MotorShield to sweep the gun left and right, reads the two bump switches to know when to change direction, and listens to the primary Arduino to know when to stop rotating when a target has been acquired.
For the primary Arduino enclosure, I started with a cast aluminum project box. It has a few holes in it from a previous project, but that’s alright, consider it ventilation. I marked and drilled holes for screwing the Arduino in place, as well as three large holes on the side for wiring, USB access and power plug access. Standoffs would have been nice, especially if I’d tapped screw holes for them, but I went low-tech and used adhesive rubber bumpers to hold the board away from the case.
Once I’d screwed the Arduino in place with some 4/40 screws and nuts, I stacked on the 7-Segment shield and a ScrewShield for wiring (full disclosure, I’m one of the WingShield Industries guys who makes the ScrewShield). I also mounted the relay circuit board to the inside wall of the case. I ran all the wiring through the hole, and can now mount it onto the gun’s stand.
Part 7: Secondary Arduino enclosure
I showed the enclosure for the primary Arduino in the previous post in myArduino Nerf sentry gun build series. This is the enclosure for the secondary Arduino — the one that drives the MotorShield to sweep the Nerf gun back and forth. It’s a Chameleon Enclosure that I slightly modified with a nibbler so I could drop the board low enough to fit the Arduino, MotorShield, andScrewShield. I also re-drilled the standoff holes 1/4″ back from the faceplate to give the ScrewShield proper clearance.
Here it all is, pre-enclosure:
And here it is enclosed:
You can see I have a variety of cables running out of the box. There’s a four-wire, DB-9 terminated bundle for the two bump sensors, a two-wire, Molex power-connector bundle for MotorShield output to the motor, a two-wire, 5.5mm female jack for MotorShield 12V power, and a two-wire, AMP header bundle for serial communications between the Arduinos.
Part 8: System Assembly
Things are getting exciting now in the Arduino Nerf sentry gun build! I’ve connected the main components together now — primary Arduino, secondary Arduino, motor, and power for the gun (I decided to removed the six D cell batteries and power it from an AC-DC transformer).
Here’s the Molex connector I soldered in place of the battery pack.
I cut a window into an aluminum chassis, and mounted the ultrasonic PING))) sensor inside. I attached it to the Nerf gun using a super-strong 3M version of Velcro.
The connector jack I mounted in the grip for the trigger wire was flopping around too much, so I secured it with a little bit of Sugru silicon molding clay. It’s excellent for this kind of fix. However, I found my hands were slippery like Teflon afterward, right when I had to screw in a zillion little screws.
Part 9: Firing tests
Here’s a quick couple of test videos of my Arduino Nerf sentry gun in action. When my hand gets closer to the PING sensor than my initial value (in this case, very close), the gun stops sweeping and starts firing.
I didn’t have ammo in the first few belt casings, so I avoided getting shot.