Introduction: Arduino Airsoft Turret
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
Arduino Mega Protoshield from Sparkfun
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
(optional) Laser pointer
(optional) Wireless Camera
Hot glue gun
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")
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
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:
Attach the turret to an autonomous car
Track a laser pointer