National Robotics Week Robot Contest: Age Group 13-18 

Whether you are fighting in an airsoft battle, or defending your desk at work, an airsoft turret is a must have.  In this Instructable I will explain how to make a relatively cheap and simple turret based off of an Arduino Mega.  Once you have the basic turret built, there are many cool things to add that can make the turret a lot more complex and fun to play with.

Here is an example video of what you can do with the turret:

Step 1: Materials and Tools

While it seems that there are a lot of parts required, this project can be done on a relatively cheap budget depending on where you buy the parts.  The following parts are what I used to make my turret, they do not have to be exactly the same.


Crossman R-71 Airsoft gun
Airsoft bullets

Arduino Mega
Arduino Mega Protoshield from Sparkfun
BlueSmirft-Bluetooth Modem
VEX 9.6V battery
(2) VEX Continuous Rotation motors
VEX Extension Cables
Assorted electronic parts *See airsoft gun electronics page

Assorted VEX metal
Assorted VEX screws and nuts
(2) VEX 84-tooth gears
VEX 12-tooth gear
VEX 36-tooth gear
VEX axles

FoamCore board
RoboRealm Software
(optional) Laser pointer
(optional) Wireless Camera

Hot glue gun
Soldering iron
X-Acto Knife
Wire cutters/strippers

Step 2: Constructing the Base

The base is one of the most important parts of this project.  It protects all of the electronics and gives the main turret a surface to operate on.  I recommend making the base out of foamcore board because it is very sturdy and relatively easy to work with.  In essence the base is just a cardboard box.  The dimensions are not exact, you just have to make sure the box is big enough to hold all of the electronics and batteries. 

The following steps are a rough plan on how to make a sturdy base:

Cut out 4 pieces of foamcore board 5"x9.5"-These will act as the walls.  One key step that makes the turret work a lot smoother is cutting out a notch to rest the cross beam in.  In the photo you can see where the cross beam sits in the middle of the box.

Cut out 2 pieces of foamcore board 9.5"x9.5"-These will be the top and bottom of the base.  On the top piece make a hole in the very middle of one of the pieces.  This is where the main axle will go.  Make another hole 2.5" away for the drive axle.

Hot glue all of these pieces together making a strong and sturdy box. 

The base is finished!

Step 3: Modify Airsoft Gun

In order to make the turret move smooth and quickly, we need to make the gun lighter and less bulky.  I started out with the Crossman R-71.  I took off the rails from the side to make it lighter and I cut off the handle to make it mount easier to a piece of VEX metal, by doing so I also removed a lot of weight from the gun.

To control the gun from a microcontroller you have to use a special circuit.  The following diagram lets you turn the gun on and off by using a digital port on any microcontroller.

In order to hook this circuit up  you have to open up the airsoft gun and find the motor that fires the actual bullets.

Step 4: Build TheTurret Frame

To build the actual turret frame you need the VEX motors, gears, screws, and nuts.  I recommend using a long piece as the crossbeam to support the turret from underneath.  This piece has the pan motor and gears attached to it.  The entire turret rides on the 84-tooth gear. 

On top of the 84-tooth gear, build a simple U-shaped bracket out of the VEX metal.  This is going to be the bracket that allows the gun to tilt up and down.  On one of the sides of this U-bracket, attach the motor and 12-tooth and 84-tooth gear.  By using a small gear to drive a larger gear, the turret can tilt very precisely and smoothly.

Attach the airsoft gun to the 84 tooth tilt gear.  I did this by hot gluing the gun to the gear and to a piece of metal attached to the tilt axle.

Step 5: Electronics Set-Up

The electronics in this project are pretty simple.  The base configuration involves 2 motors, an Arduino Mega, and a Bluetooth adapter.  Nothing else!  But if you wanted to really jazz up your turret you can add all kinds of great accessories, such as a laser pointer, a bumper switch to act as a "kill switch", an ultrasonic sensor to determine how far away a target is, and much more.

The Arduino Mega is perfect for this project because it is a very flexible microcontroller.  There are more than enough analog and digital ports to handle all the accessories that you might use.  While a Bluetooth adapter is not necessary, it makes the turret a lot more functional.  Without the adapter you have a turret wired to your computer, with the adapter you have a wireless sentry gun that can go anywhere in your house(with in range of the Bluetooth).  For information on how to hook up the BlueSmirf adapter see the SparkFun website.

As for batteries, I used the battery that came with the airsoft gun to power the gun.  I just removed it from its plastic case and put it in the box.  I used the VEX 9.6v battery to power the Arduino, the motors, and the BlueSmirf adapter.

Step 6: Talking to the Computer

In order to control the turret and use its full potential, we need to have the Arduino Mega communicate with the PC.  This is done over a virtual serial port using the BlueSmirf adapter.  While there are many different programs that let you communicate over a serial port, I like to use RoboRealm.  RoboRealm is a great software that lets a user analyze video and do different things with webcams, such as motion tracking, tracking a red ball, and much more.  Another great feature of RoboRealm is it supports communication between the PC and many different microcontrollers.  This is accomplished by loading a special program onto the Arduino Mega to communicate with RoboRealm. This attached program should be loaded onto the Arduino Mega.

For more information on communicating with the Arduino Mega click here.

Step 7: RoboRealm Set-Up

 Using VBScript code you can convert any input into motor commands.  This is the code I used to convert a USB joystick (range:-1000 to 1000) to motor commands(1400 to 1700):

xvalue = GetVariable("xvalue")
yvalue = GetVariable("yvalue")

motorx=round( (xvalue*.2)-1500)*-1

SetVariable "motorx", motorx
SetVariable "motory", motory

Using this simple code you can make the turret do many different things.  For example, if you wanted the turret to track motion you could use the Movement module in RoboRealm to eliminate everything that doesn't move.  Then you could use the Center-of-Gravity Module to find the coordinates of the movement.  Using the above code you could then have the turret track the motion. (You might have to change the middle 2 lines to depending on the range of the input).  The middle 2 lines is where the math is done to convert between the two ranges. The next step shows some different ideas on what to do with the turret.

I attached my code that moves the turret with a joystick.  There are some special features in my code such as a bullet counter, a low bullet warning, and a laser pointer control.

Step 8: Video Example

This is a video of  the turret in action.  The first part of the video demonstrates the turret  controlled by a joystick. You can really see the full range of motion the turret has.  The next part of the video shows the accuracy of the gun.  Surprisingly, the turret is very accurate.  In the video you can see that the gun is so accurate that the 4th bullet doesn't even stick to the target because it hits the previous bullet.  One of the cooler uses of the turret is color tracking.  Using a wireless camera mounted to the front of the turret, I can track a green circle taped to my hand.  The last part of the video shows how this tracking is accomplished in RoboRealm.

In conclusion there are many amazing things that are possible once you have the basic turret built.  Some of the future things I want to do with my turret are:
Wiimote controlled
iPod Controlled
Attach the turret to an autonomous car
Track a laser pointer
<p>I should make one in my room, but somehow it hsould now me, this way my brother won't get into my room again!</p>
<p> I will take this to the paintball next time :) Just sit back in the cover and watch them scream!</p>
<p>Great Pal, congratulations for your effort.</p>
<p>Nice idea! When did the idea came up to you?</p>
<p>i like it but why do you have too take off the barrel? </p><p>(great aim!)</p>
<p>next project: face detection :D</p>
<p>can you make me one, i have no clue what these words mean</p>
Where do you explain how to connect the servos??? Also is it necessary to use VEX servos??? Great ible by the way. Thanks
It was beautiful. I hope good luck on the next project
I liked that scene in Aliens where they had the auto turrets killing them off. Also played this lesser know game called Fireteam and u could find auto turrets in there for protection. Looks pretty nice but work places I've worked don't allow weapons even toy ones these days :( Nice accuracy.
could you use a paintball gun for this turret with the same electronics? such as a spider pilot ACS, get back with me on this ASAP PLZ!!!
Mostly yes you will probably need better motors for moving the gun around
Check out this link: https://sites.google.com/site/projectsentrygun/home<br>A lot of cool stuff, helpful to.
I am currently working on a Paintball Sentry as well so I can tell you don't base it off this instructable as this is built for a much lighter weapon to be mounted. Yes the electronics are the same but as for the same turret very unlikely.
Great work! I'll trade you some autonomous code for some joystick code... https://sites.google.com/site/projectsentrygun/<br>
man that amazng work u did i really want to build one i have a question if all i do is use the joy stix will i have to have the pc to power it . what im meaning is if i took it to a air soft game just have the joy stick and mount a laser on on the gun can t run without the pc <br>
That was awesome :D
omg, thank you sooooooooo much for that diagram and showing the actual required components , lol, sometimes saying u need a transistor is not enough, but you have shown which ones, so thanks again
Does it have to be an Arduino Mega or can it be any other Arduino because I kind of have a tight budget.<br><br>-TheWaddleWaaddlle
It can be any Arduino. Changing Arduinos could potentially cause some unforeseen changes though. I chose the Mega just because it has a lot of ports and chances are you won't run out.
Where does the red wire from the Arduino Digital Out Prt go to or is it just not used?<br><br>-ThewaddleWaaddle
It is not used. You can simply cut it off.
wow it's cool project....<br>how about using openCV ?...its can more interesting, i think
Did you modify the VEX radio receiver to become a housing for the BlueSMIRF? How did you attach a duck antenna onto a BlueSMIRF?
Yes, I opened up the VEX radio receiver and took out the electronics. Then I mounted the BlueSmirf in the &quot;hollowed out&quot; radio receiver. I did this just to make it easier to mount the BlueSmirf on any VEX metal. As for the duck antenna, I bought this <a href="http://www.sparkfun.com/products/158">adapter</a> which fits perfectly with this <a href="http://www.sparkfun.com/products/145">duck antenna.</a><br>
Nice!<br><br>Love to see a subsequent ible incorporating autonomous control- robot sentry bot!
Great work!<br> <br> This is the first of the sentry ible's that can actually convince me to build one!<br> <br> Although perhaps it would be more accesible if you could perhaps make a &quot;sentry for dummy's&quot; ible because some of the steps like building the gear frame and the electronics aren't really accesible for an amateur noobie like me...<br> <br> Also a tip, put the video also on the first page ;) with it on the first page you'll avoid show us a video of it comments and it'll generate more attention and traffic :)
Wow really cool! Can't wait to get an Arduino and try this myself!

About This Instructable




More by 12grahamb:Automatic Poker Chip Sorter VEX Scoreboard Whiteboard Erasing Robot 
Add instructable to: