Introduction: Autonomous Sentry Turret

About: My name is DJ and I previously made electronic whatsits, 3D-printed thingamabobs, and laser-cut kajiggers for the Instructables Design Studio; now I build and repair puzzles for Particle Industries.


The Autonomous Sentry Turret is a standalone system capable of detecting and neutralizing unwanted intruders via a barrage of soft foam darts. Built for the office environment, the AST is a powerful piece of hardware that needs no human input (although you can remotely disable it, for y'know, safety reasons). Consisting of a modified electric Nerf gun mounted on servo mechanism, the machine is Intel Edison-powered and fitted with a long-range lidar and motion sensor. Read along to see how it's made!

New to Arduino? If this is all a bit above your head, or you need a quick refresher, I recently wrote a comprehensive Arduino guide to bring you up to speed before you try to tackle the turret.

Step 1: Parts and Materials

Step 2: Toy Gun Modification Part 1

The first step on our path to world, ehem, office domination begins with disassembling the nerf gun. I chose the CS-18 N-Strike Elite Rapidstrike as the heart of the turret, as it is reasonably compact and electronic, which means we'll be able to modify it for easy control. The gun has a lot of tiny parts that need to be removed, so I've broken up the modification into many separate steps.

First, flip the gun to lay on its side with holes up. Exercise your dominant hand, grab a Phillips head screw driver and begin the process of removing the screws. All 22 exterior screws are accessible from the same side, with the exception of the battery cap. The tail stock has screws as well, but it is a standalone assembly that pops right out when the case is open. The case doesn't have any tabs, so you can gently pry it apart once you're confident the screws are removed.

Step 3: Toy Gun Modification Part 2

The battery case has four captive screws that need to be loosened to fully separate the gun body into two parts. Once the case is out, it can be set aside, since the entire turret will be powered by a single Lithium battery anyhow. The two halves of the gun body are only connected by the negative battery lead, so you'll need to pull this out in order to fully separate the case. Once the body is split, let the loose plastic bits fall out and remove the tail stock.

Step 4: Toy Gun Modification Part 3

At its core, the gun really only has two main mechanisms: a linear actuator that pushes the darts, and a pair of drums that accelerate the darts down the barrel. It would be quite possible to make a super compact version that simply placed these in a custom enclosure, but for the sake of time it is easier just to modify the gun. In order to make the next steps easier, we'll need to unscrew the drum, linear actuator, and trigger mechanisms. They are also held in with a handful of Phillips screws.

Step 5: Toy Gun Modification Part 4

With the mechanisms separate from the case, we can now dive into modifying the actual circuit. The gun has a lot of momentary safety switches to prevent the gun from running without being properly closed and triggers held. We'll be controlling this electronically, so rather than physically closing the switches, we'll just solder them permanently.

Red Wire:

This is the main power wire from the battery case. Since we won't have the case in place, we can just snip the wire after the switch and use this as the 6V+ lead.

White Wire:

This switch engages the accelerator drums. At first I thought it might be useful to spin them up via a separate circuit, but in practice the gun shot just as far when both the drums and actuator were turned on simultaneously. Simply cut the wire leading to the switch and solder it to the board where the other wire from the switch was previously.

Grey Wire:

This is a simple ground wire. Snip it at both ends to remove it from the circuit.

Blue, Green, and Brown Wires:

These are attached to the trigger switch. These can just be shorted across the DPDT switch. Make sure they don't short to each other!

Step 6: Painting

This step is quite optional, but give the turret a little more intimidating look. With the electronics removed, I decided to coat nearly everything in a couple coats of black paint+primer. Now is also a good time to cut the leg and body plates from 1/4" plywood. I've attached the vector profiles above.

Step 7: Sensor Mount

On to the sensor mount! This component provides a secure mounting place for the PIR sensor, LIDAR, and system status LEDs. I extended the wires from the LEDs and sensor by a couple of feet. The LIDAR mounts on top of the case and has its own extension wires, so we'll get to that later. The battery case nuts are 4-40, so I designed the mount plate to fit right over where it used to be with three new 1" 4-40 screws.

Step 8: Toy Gun Modification Part 5

With the gun painted, its circuit modified, and the sensor plate built, it's time to pack everything back into the gun body. There's very little clearance around the drum mechanism, so the wires from the PIR sensor and LEDs need to be fished through its base. After that, the power wires for the gun and sensor need to be retained by the original retainer piece, which you can see between the two mechanisms in the second photo. The wires extend out the top of the gun (soon to be the bottom) near the linear actuator. With everything in place I suggest testing the power connections one last time before sealing the gun up as it's quite tedious to screw and unscrew.

Step 9: Laser Mount

The laser fits into a small aluminum tube that fits where the gun "sight" pieces used to be. The provides a mounting point for the laser, as well as a rigid, yet non-permanent, way to adapt the base of the gun to the servo mechanism.

First, screw the two riser plates into the dual channel plate

Then, slide the risers through the center hole.

Extend the laser wire leads by a foot. Extend the signal wire by two feet.

Wrap a small amount of electrical tape around the laser to increase its diameter.

Stuff the laser into the end of the tube.

Fit the tube into the base of the gun and fasten any loose screws to secure it.

Step 10: Lidar Mount

Extend the LIDAR VCC, GND, and I2C lines by a couple feet. (I used ribbon wire to keep things compact.

Mount the LIDAR to the sensor plate with four 6-32 x 1/2" spacers and screw in with four 6-32 x 3/8" screws from both sides.

Fold and tape the LIDAR wires down the side of the gun.

Combine the common 5V VCC wires and the common ground wires and heat shrink them.

Step 11: Main Circuit

The circuit connections are split between the protoboard and jumpers between the Edison and PWM board. I've attached the electrical diagram above so you can see how everything connects. The protoboard mostly serves as a power bus for the 7.4V and 5V lines to connect everything. I broke out some connections to male headers to allow temporary connections for the LED. The radio receiver and power regulator both have their own female headers for mounting to the board as well. The headers on the PWM board provide a lot of great connection points for ground and VCC. Since I2C is a shared bus, I connected the SCL and SDA lines from the PWM board to the Edison and the lines from the Lidar to the remaining headers on the PWM board. The terminal block on the PWM board should be used as the main power input from the batter connection as it has a built-in high current polarity protection circuit. The Edison and PWM board are both screwed into the larger rear plates with 4-40 and 2-56 screws respectively.

Step 12: Power System

Attach the male XT60 connector to the power leads from the battery pack (double check polarity!)

Attach the female XT60 connector to a ground wire, and the positive lead to the one of the SPST switch terminals.

From the other switch terminal, attach a power lead as well as a higher gauge wire.

Solder a 1K resistor to the higher gauge wire and the other end to the anode of an LED.

Solder the cathode of the LED to the common ground wire/

Fit the LED panel adapter, switch and LED into the small wood plate with three holes.

Attach a piece of velcro to the battery to the outer mount plate.

Step 13: Base and Riser

(2x) Screw a flat 1" shaft collar adapter to a dual channel plate

Screw the plates to both ends of a one inch by six tube.

Attach the base plate to the output of the servo block.

Attach a beam to the middle of the top plate.

Attach two round plates to the ends of the long channel bracket.

Step 14: Leg Assembly

Lay a leg plate flat on a table.

Per leg, pop in eight of the spacer pieces with the triangles pointing down towards the tapered end of the leg.

Loosely bolt (2") in the top piece (with the eight hole pattern) to the inset piece (with a single hole).

Place the other leg plate on top and bolt (1-3/4") the three leg plates together.

Screw the legs to the base plates at the ends of the long channel.

Step 15: Software

The software is a single Arduino style C++ sketch running on the Edison. I've zipped the code as well as the associated and library for the LIDAR Lite. Once the library has been added to your IDE, you can download the code to the Edison!

Step 16: Loading Tips

Load cartridge with 18 eighteen darts and pack it in. Sometimes the darts don't align properly with the linear actuator, so they need to be adjusted. Simply pop it forward with your finger until the dart rests right in front. This will prevent a jam.

Step 17: Operation

The turret has four modes of operation that autonomously switch states, but it can also be explicitly configured with the remote.

Disarmed (Button B):

LED: The green LED will be lit.

SENSORS: Lidar readings are stored at roughly 10 degree intervals. PIR readings are ignored.

LASER: The laser is on.

SERVO: The servo sweeps continuously with brief pauses while gathering LIDAR readings.

MISC: The Edison with enter this state on boot.

Armed (Button A):

LED: The red LED will be lit.

SENSORS: Lidar readings are stored at roughly 10 degree intervals. PIR readings are ignored.

LASER: The laser is on.

SERVO: The servo sweeps continuously with brief pauses while gathering LIDAR readings.

MISC: The turret records LIDAR readings at 10 degree intervals across a 100 degree range of motion. If a sensor reading has been taken previously and if the absolute value of this change is greater than a certain threshold, the turret will enter firing mode.

Firing (Button C):

LED: The red LED will be lit.

SENSORS: Lidar and PIR readings are ignored.

LASER: The laser is on.

SERVO: The is paused at the current angle for the duration of firing.

MISC: This is the only state when the gun is powered via relay. After firing the turret will go to sleep to allow a new magazine to be reloaded.

Asleep (Button D):

LED: The green and red LEDs will be off.

SENSORS: LIDAR readings are ignored, but PIR readings are stored.

LASER: The laser is off.

SERVO: The servo is stationary.

MISC: The unit will wait until the PIR detects motion and then enter disarmed mode to continue gathering readings. As is this will require someone to manually re-arm the turret with the remote. The code will have to be edited to switch to armed mode to have a totally standalone solution. The gun can usually fire about three separate times before requiring a new magazine.