Arduino Nerf Turret

Overview

This started out as a small project to see if I could remote-control a Nerf gun. The Stampede was an obvious choice since it's "trigger" is just an on-off switch and it's fully motorized and automatic I didn't have to worry about how to "cock" it or "pull" a trigger, I could simply turn the power on and off to "fire" it. My objective was to add a remote-control port to the gun while retaining it's "original" operation as a toy when it was unplugged.


Design

To begin, I broke the project into several smaller parts that could be completed independantly of each other.

Stock wiring:

In the stock wiring, when the trigger is pulled the "Fire Trigger" switch is changed from shorting the motor (fast-stop) to powering the motor (shoot). After approx. 150ms the motor has moved into a position where the firing mechanism physically holds the Fire Trigger switch in the "run" position until the dart has finished firing, at which point it will return to "stop" if the trigger is not still held.


Fire Control Relay Wiring:

To begin, I added a relay to the circuit. It is wired such that the relay defaults to the original circuit path but when activated, it connects the motor to the "+" power where it comes into the original trigger switch. It is important to connect to the power after the safety switches or the gun could turn on unexpectedly via the remote-trigger while clearing a jam or changing clips and cause injury.


Fire Control Relay Wiring Part-2:

Next, I modified the circuit to accept the low-voltage low-current of a microcontroller for triggering. This used a MOSFET transistor to trigger the relay, drawing power from the Nerf gun's battery pack to power the relay.

The zener diode serves both protection for the MOSFET and (in combination with the 100 ohm resistor) regulates the voltage to the relay. Using a 5V relay helps proper operation when batteries are low or the motor is starting resulting in the 9V supply sagging to a lower voltage.


Barrel Detector Beam-Break Sensor:

While firing under automation I needed to gather information about the state of the gun. This included determining statistics to program it (e.g. how long it takes to cycle) and also identifying if the gun jams or runs out of ammunition. To accomplish this, I designed an optical break-beam sensor that provides feedback about the darts that are fired. As an added bonus "for fun", this could be used to comptue the velocity of the darts leaving the muzzle by measuring the amount of time the dart blocks the sensor and measuring the length of the dart.

Light should be kept out of the detector area for most accurate detection. For the Nerf Stampede this meant taking the tube out of the barrel and painting the outside of the "inner tube" black as well as painting the inside of the "case" of the gun black to reduce the external light.

Output of the "Detect" pin will be very little current (~1mA) at the voltage set by "Vout Limit" Zener Diode. This can be used to control a mosfet, transistor, or IC. For a 5V Arduino, Vout is a 5.1V Zener Diode. For Raspberry Pi it should be 3.3V Zener Diode (though 3.3V might also work for Arduino, I have not tested this).

When no object is blocking the sensor beam, "Detect" will be high (+ volts). When there is an object blocking the beam, "Detect" will be low (0v). There is also a diode and filter capacitor to help reduce "noise" introduced when the motor starts/stops.


Assembly

The componants were installed into the gun by drilling/dremeling small holes in the plastic to run wires thru and then hot-gluing the larger componants in place. The sensor in the barrel is held in place with tightly-wrapped electrical tape which is sufficient to keep it aligned until the case is re-assembled to clamp it firmly in place.

Barrel Detector Beam-Break Sensor:

Close-up of the optical break-beam sensor


Barrel Detector Beam-Break Sensor:

The wiring for the optical break-beam sensor runs carefully back to the main part of the gun, following the "safety switch" wiring to avoid getting caught in any moving parts.


Fire Control Relay:

Close-up of the relay with the MOSFET, resistors, and zener "spidered" onto it and covered with shrink-tubing to protect it.


Final Assembly:

Overview of the gun with all the componants installed.


Final Assembly:

Post-assembly view of the remote-control interface jack in the bottom rear of the gun.


Software

The software should be self-explanitory, I have posted most of my sourcecode on GitHub. There are several Arduino sketches with code for benchmarking the gun (printing stats about fire rate, velocity, etc.) as well as controlling one gun and a pair of them firing alternately. The code used in the YouTube video is in "nerfTurret2.ino".


Conclusion

Overall, the results were good. I was successful in the modifications and it worked about as well as planned. The wire I used is probably a bit undersized but it's what I had on hand and was good enough.