Introduction: Gamepad Controlled Nerf Gun

Nerf Guns are fun, handheld dart blasters that once took the world by storm. The Nerf Jolt is a $4 dart shooter that packs a huge punch. What if you could control it using your keyboard, or PS4, Xbox, or other video game controller wirelessly?

This project will walk you through how I designed my wirelessly controlled Nerf Gun through the use of Arduino and 3D Printing for approximately $30 USD.

This is a bit of both of a tutorial and a general explanation of my design process. I'm aware that my design is not perfect, and there is always room for improvement. I'll try to make a note of design flaws I made especially so that you can think of ways to avoid them. I sincerely hope that whoever decides to take on this project improves my design and passes it along to others.


To make this project, you need:

  • Nerf Jolt $4.00
  • 3D Printer + Filament $Pre-Owned
  • Arduino Uno + Breadboard $10.00
  • 3 x MG996 Servo Motors $12.00 (always try making an offer on eBay before paying the requested price!)
  • Hot Glue Gun, Hot Glue $Pre-Owned
  • (Optional) Zip-Ties $Pre-Owned
  • Large Metal File or Low Grit Sandpaper $Pre-Owned
  • Any USB or Wireless Gamepad Compatible with PC $Pre-Owned

Step 1: 3D Printing Components

This project requires you to 3D Print three servo mounts and a custom servo horn. As mentioned in the supplies list, these are designed to fit MG966R Servos that I bought off of eBay for $12.00. I have included the STLs for you below on Thingiverse.

These were printed at approximately 10% infill, no build plate adhesion, in a generic white PLA.

There is mild stringing under the lip of the servo mounts, you may want to play around with print orientation and speed, but it is nothing serious. You can easily remove the stringing bits with a wirecutter.


Step 2: Placing the Servos

The servo mounts are designed so that the servo can only be inserted in the proper positions, with the wires coming out through the designated slot. These should fit snug as-is, but in case your printer makes these too loose, you may screw them into the mount. For the tilt and pan servos, you may choose any of your included servo horns. Do not forget to screw these into the actuator.

I designed these so that they perfectly fit my servo, they only have a 0.2mm clearance on each side of the motor. With inevitable print imperfections, this allows for a tight fit. In my initial design, I forgot to make room for the servo's wires, so if you're designing your own, make sure to account for that.

Do not yet place the custom 3D printed servo horn on the firing servo.

Step 3: Filing the Gun and Attaching the Servo Horn

To make a servo horn properly fit onto the Jolt, you may want to use a metal file to create a flat edge for the plastics to connect. A flat face allows for more surface contact between the pieces, leading to a better bond.

You may hot glue these two together. Again, I advise screwing the horn onto the servo before gluing. In the picture above, it is not yet screwed, just for ease of taking a photo.

Step 4: Glue the Servos Together

You may now hot glue the servo horn on your pan servo to the 3D printed casing that contains your tilt servo. Simply put glue atop the pan servo horn, and hold it against the tilt servo's plastic case. Like-wise, you will want to take the tilt servo's horn, and press it against the filed handle of your gun with a sufficient amount of hotglue. The order in which you choose to do this does not matter. Make sure the servo that is in the base with a plus-sign like shape.

If I were to redesign this part, I would add a bit of a "cavity" in the shape of a servo horn onto my tilt servo. That way, when I press the pan servo's horn against it, it would be an even snugger, even more secure fit. It does work as-is, but this is not the world's most elegant solution.

Step 5: The Firing Servo

Attaching your firing servo requires you to assemble in the following order:

  1. Place the final servo into the 3D printed firing servo mount
  2. Attach the 3D printed servo horn to your servo, such that it is just barely not touching the trigger of the gun. Be sure that your servo has enough room to rotate that the horn will eventually make contact with the trigger.
  3. Use a large amount of glue to attach the servo horn to the blaster. Depending on the quality of your print, you may need to file edges of the blaster's barrel down to create a flat edge for the mount to rest on.

I had a poor quality glue gun, and even ran out of glue during this step, so I had to use zip ties in addition to the glue gun. If I ever decide to remake this project, I would definitely consider designing a new method of mounting this final piece.

If you are planning on making your own version of this gun, and are capable, I would advise making a bracket that screws together around the barrel of the gun to mount your servo. I only thought of this idea after finishing my own design, and it would be more hassle than it is worth for me to redo this.

Step 6: Programming in Arduino

The gun uses a code designed to run on an Arduino Uno, although I see no problems using it on other microcontrollers like RPI or an ESP8266 in MicroPython. I have attached the following Arduino program. I connected the tilt servo to pin D10, pan to D9, and firing to D8. All share a common ground the Arduino using the brown wire of the servo, and receive +5V on the red wire from the microcontroller.

The code initializes all three servos to their proper pins, and declares a range of angles for them to rotate between. Tilt and Pan can freely roam between 0~180 degrees, but you'll need to figure out your firing angle on your own; it depends what its initial position was when mounting.

The Arduino is constantly reading for commands in its serial monitor, which will be sent by Processing in the next step. If an "Up" command is sent, it increases the tilt angle by tiltSpeed (which I made 3 degrees). "Down" will do the opposite, and decrease. Similarly, left and right will change by panSpeed.

Reading a shootGun() command will cause the fireServo to suddenly retract, hold that position for 0.5 seconds, and release again as to not burn out the servo motor. Once again, you will need to find the contract/release angles on your own. I would advise doing this by just guessing and checking various angles in the Arduino code and seeing the results; it doesn't have to be an exact process!


Step 7: Programming in Processing

To read your keyboard inputs, you require Processing. You can download this here. Play the linked script to control the gun.

You can think of this as the partner to the last Arduino script. Processing is constantly sending signals to the Arduino, a 0 for a 'W' press on your keyboard, 1 for 'S' and soforth. I had the attached image open in my window, but if you don't want this (don't worry, I won't be offended haha), I have already commented the lines out for you.

Use the WASD keys to move the gun, and the 'X' key to fire. The Processing window needs to be open in order for you to operate the gun.

If you wish to use a gamepad, proceed onto the next (optional) step.


Step 8: Using Joy2Key

To achieve control using a gamepad, you require one final program: Joy2Key. Joy2Key is a program typically used to play videogames that lack controller support. It maps presses from your gamepad to an emulated keypresses on a virtual keyboard. For instance, in this project, we will map the D-pad on your game controller to WASD, and the X (or A if you're using an XBOX controller) button to 'X'

Each of the directional buttons has autorepeat enabled at 30hz. If this mode was not on, you would have to physically click the button each time you wanted to move 3 degrees.

That's it! Your gun should now be fully automated, aside from the unfortunate manual reloading. Hopefully, you thought of some fun ways to either duplicate or improve upon my design. If you do decide to make mine better (believe me, I know it's not perfect), please share! I'd love to see it, and I'm sure others will too.