Introduction: Motion Activated Gun Turret

In this project I am going to show you how to use motorized nerf guns and water guns to make automated gun turrets that you can use to shoot your friends.

The gun is controlled with an Infrared Motion Sensor and an Arduino microcontroller. The motion sensor detects when someone walks in front of the gun. The Arduino then activates a relay that is connected to the trigger and fires the gun. You can set it up in a hall or in a doorway and it will shoot anyone who walks by. This is a fun way to prank your friends.

Step 1: Watch the Video

Here is a video walkthrough of the project.

Step 2: Materials

Here are the materials and tools that you will need for this project.


Motorized Nerf Gun or Water Gun

Arduino Microcontroller

USB Connector Cable/Power Supply

Relay with a coil current of 30 mA or less (example: )

Jumper Wires

Small Diodes

Perf Board

Wooden Board

Small Machine Screws

Insulated Project Enclosure


Screw Driver

Soldering Iron and Solder


Step 3: Select a Motorized Toy Gun

The first thing that you need to do is find a motorized toy gun that continuously fires projectiles when you pull the trigger. There are a lot of different kinds to choose from. Most of them will either be a Nerf style gun or a water gun. Any of these will work as long as you can access the firing switch.

For this project, I am using the "Cyclone Water Blaster." This is an automatic water gun that is designed to mount to a bicycle handle bar. I chose this one because it has a built-in motor that turns the gun from side to side. This allows me to hit a wider area. The handle bar attachment also made it easy to mount it to a platform.

Step 4: Open the Housing and Locate the Firing Switch

Now you need to open up the housing of your gun and locate the firing switch. In most cases this will require you to unscrew the whole side of the gun. In my case, the firing button is an external switch that is connected to the gun with a set of wires. So I just had to open up this smaller housing.

On some guns the housing may be glued together. If this is the case, use a knife to cut the plastic along the seam. Work slowly and be careful not to accidentally crack the plastic as you cut.

Step 5: Solder an Extension Wire Onto Each Switch Terminal

In order to be able to control the gun with an external circuit, we need to solder a wire onto each switch terminal. On most guns this will just be a single switch with two terminals. But my gun has three switches. There is one wire for each switch and a fourth that acts as a common positive terminal. So I soldered four extension wires onto the circuit board. After soldering the wires, I wrapped the board in tape to help insulate the connections.

Step 6: Arduino Code

//Before you can control the gun, you need to upload some sample code to your Arduino.

// Here is some sample code that you can use to start the project.

//Just download the file or copy and paste the text into a new sketch.

int relayOne = 2; // Relay connected to digital pin 2 int relayTwo = 4; // Relay connected to digital pin 4 int relayThree = 6; // Relay connected to digital pin 6 int motionSensorPin = 13; // Motion Sensor connected to digital pin 13 int motionSensorState = 0;

void setup() { pinMode(relayOne, OUTPUT); // sets the digital pin 2 as output pinMode(relayTwo, OUTPUT); // sets the digital pin 4 as output pinMode(relayThree, OUTPUT); // sets the digital pin 6 as output pinMode(motionSensorPin, INPUT); // sets the digital pin 13 as input Serial.begin(9600); }

void loop() { motionSensorState = digitalRead(motionSensorPin); //read output of motion sensor

if (motionSensorState == HIGH) // if motion is detected, fire gun { digitalWrite(relayTwo, HIGH); // turns the second relay on to fire the gun delay(1000); digitalWrite(relayOne, HIGH); // turns the first relay on to turn the turret delay(150); digitalWrite(relayOne, LOW); // turns the first relay off delay(500); digitalWrite(relayThree, HIGH); // turns the third relay on to turn the turret back delay(300); digitalWrite(relayThree, LOW); // turns the third relay off delay(500); digitalWrite(relayOne, HIGH); // turns the first relay on to turn the turret delay(300); digitalWrite(relayOne, LOW); // turns the first relay off delay(500); digitalWrite(relayThree, HIGH); // turns the third relay on to turn the turret back delay(300); digitalWrite(relayThree, LOW); // turns the third relay off delay(500); digitalWrite(relayTwo, LOW); // turns the second relay off to stop firing the gun digitalWrite(relayOne, HIGH); // turns the first relay on to turn the turret all the way to one side delay(700); digitalWrite(relayOne, LOW); // turns the first relay off delay(500); digitalWrite(relayThree, HIGH); // turns the third relay on to turn the turret back to the center position delay(425); digitalWrite(relayThree, LOW); // turns the third relay off delay(1000); }

else // if no motion is detected, default to setting all motors off { digitalWrite(relayOne, LOW); digitalWrite(relayTwo, LOW); digitalWrite(relayThree, LOW); }


Step 7: Prototype the Relay Circuit on a Breadboard

To simulate the buttons being pressed I am using a set of relays. The relays are connected in parallel with the switches on the gun. One side of the relay switch needs to be connected to each side of the switch on the gun. When the relay is turned on, the functions on the gun will activate just as if the button had been pressed.

The relays that I used only required 20mA to activate. So I was able to connect them directly to the Arduino. If your relay requires more than 30mA, then you need to use some kind of driver circuit to activate it. You can also use an Arduino relay shield.

Any time that you have a relay connected to a sensitive circuit such as a microcontroller, you should connected a diode across the terminals of the relay coil. This helps to prevent damage from the voltage spikes that occur when the relay turns off.

First I prototyped the relay circuit on a breadboard. Then I connected the wires from the gun and the Arduino. This let me test it out to make sure that I could control all the functions with the Arduino. Once that was working, I connected to the motion sensor.

Step 8: Solder the Relay Circuit Onto a Piece of Perf Board

Once the circuit is working properly, solder the components onto a printed circuit board or perf board.

Step 9: Mount All the Parts Into a Project Enclosure

To keep all the parts neatly together, I mounted them all inside a plastic project enclosure. I used a hole saw to cut a large hole in one end of the enclosure. Then I attached the motion sensor to the inside of the hole with hot glue. The Arduino and the other two circuit boards were also attached to the inside walls of the enclosure with hot glue. Lastly I cut slots in the side of the housing for the power cord and the cable that connects to the gun.

Step 10: Mount the Gun on a Platform

Now you need to find a way to mount the gun. I just attached my gun to a small wooden board. This was portable enough to be easily carried around and stable enough for firing.

In order to make room for the water canister, I used a piece of 2x2 lumber to raise the gun up off the platform. This allowed the gun to rotate without hitting anything. To accommodate for this extra piece, I had to replace the original screws with longer ones.

Step 11: Finished Motion Activated Gun Turret

Now your motion activated gun turret is complete. Set it up and wait for your unsuspecting victim to walk by. When they do, your gun will automatically sense them and shoot them.


CapeScanner (author)2017-05-29

This would be great for scaring away critters in the garden. Would something as small as a chipmunk set it off?


It depends on how close it gets.

Koustubh007 (author)2016-01-20

hey very nice project I am using a nerf gun instead. can you tell me the range of our sensor


That depends on the specific sensor that you use.

NoahMan (author)2015-11-22

That is a good security device :)

GavinN made it! (author)2015-08-02

I made it to scare away the ducks from the edge of my pool. Works a treat!


That is awesome. Thanks for sharing.

Kit Master (author)2015-06-06


coolblaze19 (author)2015-05-01

lol this would be great for water wars

MasonF (author)coolblaze192015-05-05

unless of course water gets into the project enclosure somehow

alexandraroach1 (author)2015-04-29

How would one modify that to work for zombies?


To be honest, I am not sure how you would distinguish zombies from regular people.


People can read "Beware Death Device"

About This Instructable




Bio: My name is Jason Poel Smith I am a Community Manager here at Instructables. In my free time, I am an Inventor, Maker, Hacker, Tinker ... More »
More by DIY Hacks and How Tos:36 Things to Cook in a Coffee MakerHow to Make a Festivus PoleAdd Wings to an Infant's Halloween Costume
Add instructable to: