Instructables
Picture of Das Uber Airsoft Gun Turret
This Instructable will show you how to Design, Build and Trouble Shoot an Airsoft Gun Turret with a USB interface. The turret can be toggled between Manual Mode, where a Human interfaces with it using an Xbox 360 Controller, or Automatic Detect and Fire Mode, where the turret springs to life and detects any human presence in its surroundings. Firing at Humans is not advised.

A Special Thanks to Colin. For helping me with the WebCam calibration concept way back when.

Visit my blog, for all other details not contained in this instructable.

Update: HACK-A-DAY Post checking out the turret. Very flattered from these guys words.
 
Remove these adsRemove these ads by Signing Up

Step 1: Get an "Electronic" Airsoft BB Gun. And Slice it open.


If you are in the U.S. Say just as the title says, go to any Department Store and buy one.

Look for guns that look easy to cut or to take apart.

After you've got your gun, open it up (follow this guide).

As you can see, it is very simple. If you power the motor, you fire the pistol. Before you hack it open you do this by closing the circuit by pushing a switch with your finger as you pull the trigger. But there are many, many ways to close an electric circuit, and you can get very creative. In this project we are going to use Relays to do that.

If you are not in the U.S, this may take some doing.

I am obviously not in the U.S. but I got Lucky. A friend of mine gave me his.

'(Gracias Pinche Bronzon!! Ahi esta el Robot que te dije que iba a hacer con tu Pistola.)'

If you are in Mexico: 'jalense a los bazares o a los mercados y busquen a la gente que vende cuchillos y pistolas tipo militar. las tiendas de chucherias afuera de los super mercados (Soriana y la Comer y demas) a veces las tienen. De ultimas, preguntenle a algun amigo que le gusten las gotchas si tiene una o sabe donde comprarla. En Mexico es comun que vendan gotchas y Airsoft Guns en las mismas tiendas.'
oyu110 months ago
You should sell these dude... These are bad (as in good)
Miltron_B (author)  oyu18 months ago

Thanks! I don't think it would be profitable though.

GeckoLink3 years ago
can it be controlled without needing a computer on-site?
Miltron_B (author)  GeckoLink8 months ago

Yes. There are many solutions now days.

You cold use a Raspberry Pie!

I will probably make this, for ultimate backyard supremacy, but with a stronger gun, prob a G&G ABS M4-A1. But really cool build anyway.
bighead54545 years ago
hey hook this up to a simple selfmade rc car being controlled by a friend and use the turret while it is gion through ur enemys house
Miltron_B (author)  bighead54543 years ago
I'm working on a Sentry Bot for my new Home.

I will post the results!

resistance is futile....

Miltron_B (author)  Cadillachearseguy3 years ago
It is ineed.
mking20124 years ago
Nice!! Do you think it would be possible to make a version of this that looks, sounds and talks like the turrets from Portal?
Miltron_B (author)  mking20123 years ago
Hey, sorry for the late response. Yes! This robot uses a PC for a brain. You simply need to add the DirectX code for sound playback.
can you do one on a mac?
Miltron_B (author)  TheInventor19973 years ago
Sorry for the late response. Yes you need to use the PHP APi for the Phidgets so you can control the turret from any plataform with a browser. Even an iPod Touch or an iPad would work.
Chowmix124 years ago
Can i use micro servos for the X and Y axis? Im pretty sure i can because the bearings take off most of the weight.
Miltron_B (author)  Chowmix123 years ago
Hey,

Sorry for the very late response. yes, you can use micro servos.

The servos I used were way over caculated. The bearings help a lot with the load!

Be sure to use ball bearings for the Y Axis servo and push bearings for the X Axis Servo.
pyrocord4 years ago
 I am building an exoskeleton to mount airsoft guns on as "armor". Could this be mounted on a shoulder of an armor suit made of sheet metal? If so, how much does it weigh?
Miltron_B (author)  pyrocord4 years ago
Nice!

I think the best choice you have is to use a "Pan and Tilt" mechanism and attach it directly to the Airsoft Gun's body.

It requires only two servos and the firing signal.

Lynxmotion has some sweet pre-made "Pan and Tilt" assemblies.

As for the weight, it depends on the servos, the mechanism's material and the gun.

Good luck!
could you make a vid or something :))
Miltron_B (author)  sillyplatapus5 years ago
Sadly, the gun turret died in acction before any vid could be made. It was just too much fun playing with it to bother filming it!
this confuses me ? :o
Hey mate nice invention, I think you will be keen to see this paint ball one, let me know what you think and what software they are using?
Miltron_B (author)  donalexander5 years ago
Thanks Mate. There are several painball turrets out there. All of them are awesoem. I think the software for their robots is costum made. Probably motion tracking using openCV.
tkezic5 years ago
hi mate, can i get the software in vb 6? and the one that has the auto fire? cheers
Miltron_B (author)  tkezic5 years ago
Hi! Well, it depends on a whole bunch of things. Are you also using phidgets? If so, just get hte phidgets VB6 API to control the servos and relays. Now, sadly, the API I used for visual recnition is based in C++ (Intel OpenCV). Try googling for VB6 Computer Vision API, see if you get anything. Best of luck!
hi thanks for the quick reply. yes i am using phidgets, a polulu servo controller which i can program. would i be able to harrass you for a copy of the code anyway? cheers
Miltron_B (author)  tkezic5 years ago
Hey! Regretably, the code is long long lost in the realm on formatted hardrives and lost HDD partitions. But, it was very simple. Just grab these examples and mash them up nicely. From the Phidgets API: Servo Example and the InterfaceKit Example. From the OpenCV API: Face recognition Example. From DirectX 9.0 SDK (asumming you want to use the xbox controller): Xinput Example. With those, and the comments in them, you should be able the get it to work. The hardest part, is to align your robot with the cameras. You do this with a regression taking various data points. Oh! You need the Windows SDK for the DirectX SDK to work properlly. Also, thanks to teh DreamSpark programme, you can get VisualStudio 9 for free is you are a student. Best regards, and don't hasitate on contacting me again if you need anything else.
cheers. I have looked and looked and all i could find was the c# and i get lost within minutes of trying to figure out how to use it. i am very good with vb6, and found motion detecting software, but it gives me lots of boxes, say pic height = 50 boxes which is good for sensitivity, but the servo tries to go back and forth to all the boxes, i cant seem to get an average or centre of the x and y value. here is my code. could you help with any suggestions? thankyou so much.

Sub GetMotion()

Static Counter As Single 'counter
BoxesX = 50 'from 1 to 50 50 default on x and y
BoxesY = 50 'from 1 to 50
AveragePixelLoop = 30 'from 1 to 250 30 default

For Px = 0 To (MotionPic.Width) Step Int(MotionPic.Width / BoxesX)
For Py = 0 To (MotionPic.Height) Step Int(MotionPic.Height / BoxesY)

pixx = Fix(Px / (MotionPic.Width / BoxesX))
pixy = Fix(Py / (MotionPic.Height / BoxesY))
For Repeat = 0 To 5 ' default is 5
ColorSumStr = Right$("000000" + Hex(GetPixel(MotionPic.hdc, Px + Repeat, Py + Repeat)), 6)
ColorRedStr = Mid$(ColorSumStr, 5, 2)
ColorGreenStr = Mid$(ColorSumStr, 3, 2)
ColorBlueStr = Mid$(ColorSumStr, 1, 2)
ColorRedDec = Val("&H" + ColorRedStr)
ColorGreenDec = Val("&H" + ColorGreenStr)
ColorBlueDec = Val("&H" + ColorBlueStr)
AveragePixel(Repeat) = ColorRedDec + ColorGreenDec + ColorBlueDec
Next

Counter = Counter + 1
If Counter = AveragePixelLoop Then Counter = 1

mdSample(pixx, pixy, 0) = 0
mdSample(pixx, pixy, Counter) = 0
For Repeat = 0 To 5
mdSample(pixx, pixy, 0) = mdSample(pixx, pixy, 0) + AveragePixel(Repeat)
mdSample(pixx, pixy, Counter) = mdSample(pixx, pixy, 0) + AveragePixel(Repeat)
Next

AverageSum = 0
For Repeat = 1 To AveragePixelLoop
AverageSum = AverageSum + mdSample(pixx, pixy, Repeat)
Next
AverageSum = AverageSum / AveragePixelLoop

'preveri proženje motion-a
If Abs(mdSample(pixx, pixy, 0) - AverageSum) > mdTriger Then
MotionPic.Line (Px - 4, Py - 4)-Step((MotionPic.Width / BoxesX) - 4, (MotionPic.Height / BoxesY) - 4), , B

If pixx = 0 Then Label2.Caption = 84 Else Label2.Caption = (pixx * 5)
If pixy = 0 Then Label3.Caption = 84 Else Label3.Caption = (pixy * 3) '(MotionPic.Height / 2)
Label9.Caption = MotionPic.Height

MSComm1.Output = Chr$(255)
MSComm1.Output = Chr$(8)
MSComm1.Output = Chr$(Label2.Caption)
MSComm1.Output = Chr$(85) 'Terminate and Update

MSComm1.Output = Chr$(255)
MSComm1.Output = Chr$(9)
MSComm1.Output = Chr$(Label3.Caption)
MSComm1.Output = Chr$(85) 'Terminate and Update

Miltron_B (author)  tkezic5 years ago
The thing is, your servo does not know what those values are.

Here is what you are going to:

Find the x,y value for a single pixel you want in your image. (this will be what ever you are aiming for)

Manually move your servos so that the gun is aiming to that point in the real world (if you shoot, it's going to hit where your point is)

Wirte down the value for the servo moving your X and write down the value for the servo moving Y.

Do this for all XY points for the entire cross section of the image.

Once you have the data to what servo values correspond to what x/y value, make a mathematic regresion (you can use excell or a TI calculator to do this)

Your program should be something like:

getXPixel();
getYPixel();
servoX = regression in fuction of X pixel data;
servoY = regression in fuction of Y pixel data;
shootFace();
thankyou very much, i will try it out and let you know. your help is much appreciated. thankyou
Miltron_B (author)  tkezic5 years ago
Here is a good link on how to make Regressions with Office.

If you run into trouble let me know.

It would be awesome if you post some pics of your work in progress.

Good Luck.
geekazoid5 years ago
lol i don't speak spanish or live in mexico, but i still firgured out wat it meant.. lol dictionary (i guess i go a bit overboard)
Miltron_B (author)  geekazoid5 years ago
Awesome!
qwertyman105 years ago
2 things that would make this machine even more awesome: 1. support with bluetooth or peer to peer wifi so it could be used with smartphones or mini laptops in the heat of battle up to 100 feet away, and 2. a set of wheels and some motors to make it portable. Awesome invention!
Miltron_B (author)  qwertyman105 years ago
Hey mate! Glad you liked it. This is actually controlled by a PC already, so you just need another laptop and VNC in both machines. This way you can controll it half around the world! Making it a mobile BB tank would be awesome indeed though.
qwertyman105 years ago
that looks like a multi-thousand dollar investment.. awesome! i could take down both my brothers and both their friends with that! that thing looks so cool.
marcos1015 years ago
lol I want to see some one do this with a paintball gun. _
Ddog1965 years ago
It would be bad if you can have like three of these and plant them somewhere around in the woods (if you're playing airsoft) and being able to control each one seperately and use them to take out random targets.
Miltron_B (author)  Ddog1965 years ago
I want to make something voice controlled, and get a feed of what each turret is seeing un a small, head mounted LCD.

I just found the perfect plataform:

http://www.trossenrobotics.com/roboard.aspx
how did you come up with this? that seems a little complicated for playing around with useless junk.
kerneykid15 years ago
thats cool. really.
Lylec6 years ago
Miltron, I am sure I am missing it, but you mention an auto mode in the intro. but i cant find a description of the aiming process etc. Any stats on its accuracy? In my part of the world, just being able to paint a guy up with a Laser dot will get him running
Miltron_B (author)  Lylec6 years ago
Hola Lylec!

The automated aiming mode is very simple. The OpenCV Library has an example on face recognition. In that Example, you will see that the program draws a circle around the face it is detecting.

If you look at the code as how the program draws that circle, you will see it uses a point of the image (pixel) as a center to trace the circle. This point is almost always smack in the middle of the face.

About the accuracy, it will depend on how well you calibrate your robot.

Use the FIXED WebCam to use this pixel (in x, y, coordinate system of the image) as your reference point. In order to get the position of your servos as a function of the center point of the circle, you will need to gather at least 20 points of data across the mid-section of your screen and use a spreadsheet to do a cuadratic o cubic regresion.

That means that you will have to experimentally (trial and error) find at least 20 points where the servos are in such position, that the gun is pointing to where the center of the drawn circle is. And you have to find this 20 points across the mid section of the image.

I hope that answered your question, if not, ask again what ever you are stuck in.

Good luck in that part of the world of yours! Just don't be mean to your neighbors.

Saludos,
Miltron_B (author)  Miltron_B6 years ago
Here is a nice link that I'm sure will help you. In your case, the "Shelf Space" is the center of the circle and the "Books sold" are the position of one of your servo motors. If you want to take it further, the face recognition software also gives you a circle radius, this will be a nice indication of how far your target will be.
Lylec Miltron_B6 years ago
Thanks Miltron. And just a useful/less factoid. I live in South Africa, and Hola is also a very common/hip greeting amongst the youth (tho mainly the black youth). The theory is that during the cold war, Cuba send instructors to Angola to train soldiers (our erstwhile enemies) They obviously spoke spanish, so the greeting was passed on to their students and slowly it made its way into our local slang..... So there you go, you can greet practically any SA youth (under 35 probably) in your native tongue......
NZbomber Lylec5 years ago
what sport?
Miltron_B (author)  NZbomber5 years ago
FIFA World Cup. It's huge everywhere, except in the U.S.
Lylec Miltron_B5 years ago
I have tickets already :) only for round of 16 tho.
Miltron_B (author)  Lylec6 years ago
That story is friggin' awesome! I want to go to SA for the WorldCup 2010.
Miltron_B (author)  Miltron_B6 years ago
for got the link.
sdaw5 years ago
would you mind putting some diminsions in? i managed to get this as a school project, and i don't have much time to think about it. thanks.
slipknotFTW6 years ago
if ihad the time and stuff to do thid i so would!! anyone know where to get all the stuff from NZ??
Miltron_B (author)  slipknotFTW6 years ago
I'm visiting Australia at the moment and they get their stuff here from Dick Smith's Electronics. Maybe also in NZ? Phidgets you are goung to need to import, but you can find many good servo controllers from Ebay. Maybe Finally something Aussies have in common with Kiwwi's!?
Argon276 years ago
You, my friend are a god.
lander6 years ago
orale eso esta genial "felicitaciones"
Miltron_B (author)  lander6 years ago
A huevo. Muchas gracias.
MrNintendo6 years ago
Think it would be possible to wire this up to an alarm system and fire at the intruder when the alarm is triggered? By the way, nice intructable dude. I've been meaning to make one of these for when I go play airsoft and scare the crap out of my friends when they can't find who's shooting them.
Miltron_B (author)  MrNintendo6 years ago
Yes you could. It's very easy. Just hook your alarm system to the main power of the sentry gun and turn it on and off when ever the alarm triggers. Basically, if your alarm control has a boolean output signal (maybe a 5 Volt TTL?) use this output to actuate a relay in series with the main robots power. Good luck making yours!
Thanks!
Jfaranda76 years ago
I'm a lil confused im just getting into electronics but i think i can make this, but my question is do u need to keep it plugged in to a computer to use or can u just plug the xbox controller in use it alone?
Miltron_B (author)  Jfaranda76 years ago
The Phidgets, Controller and WebCams are all controlled by a running program in a tunerd-on PC where the stuff is all connected.
ok then if i was to mount this on a paintball tank that i have in development. what kinda power needs does this have. could i run it of the motor or could i get some big rechargable marine batterys and run it off that.
Miltron_B (author)  Jfaranda76 years ago
Both.

Pt ~= 200W.
Whoa, just as I was thinking " I should make a sentry gun and post it on Instructables..." I saw yours, great job!
Miltron_B (author)  lordofthedonuts6 years ago
Thanks mate. Make yours!
I'll sure do.
Seems like an exellent instructable however much of it is just a bit over my head. Right now i am simply experimenting with electronic components and some simple computer programs but that intrest combined with my love of airsoft makes this instructable quite interesting in itself. I think the reason why i didnt understand alot of it was because of all the abreviation and acronyms which am not entirely familiar with. If you have the time or fell like it maybe you could help explain some of it to me but if not thanks for the great idea. 5 stars in my book.
Miltron_B (author)  handyScrapper6 years ago
I'm glad you liked it. And dude, this robot uses the simplest electronics ever. The LEDs (Light Emmiting Diode) Lasers (Light Amplification by Stimulated Emission of Radiation) and the BB (Baby Bullets) Airsoft are all fired by closing a circuit. Manually, you would do this by pushing a button, or a switch. If you want to do this "electronically" you can do it by many means that I'm sure you will learn later, this time we are going to use Relays. Relays are basically switches that actuate when a nearby coil is powered and so magnetized, closing the circuit. About the other Acronyms I use, here is a quick list of what I think you may want to know: DOF - Degrees of Freedom. Usually states the number of motor required for a certain mechanism, and in how many directions can it move (ours can just move in X and Y) uC - Microcontroller. A computer stored in single electronic packaging. not used in this project. AVRs and PICs are types of uc made by different people. IDE - Integrated Development Environment. A Program that helps you avoid using notepad and the command line to program and compile. It make things easyer (most of the time) when programing. SDK - Software Development Kit. PCB - Printed Circuit Board. AC/DC - Alternate Current (The one found on a house outlet) to Direct Current (The one provided by batteries and solar panels) Converter. You use an AC/CD converter every dy to charge your cellphone or your laptop or your PSP/DS. Sorry about the acronyms, I should edit it later.
Miltron_B (author)  Miltron_B6 years ago
Forgot one...

CAD - Computer Assisted Design. Google's SketchUp is a Free CAD tool you can get from here.

Give it a try! You can do something like Alonso's first as a warm up if you think this one is too comlplex/expensive to make.

Good Luck!

Thanks so much for the help! you cleared up just about everything i was a little confused about, and even though this project may still be a little out my league (aka price range) i can at least understand how it works for projects in the future. You did go a little overboard with the explanations though, i mean come on, AC/DC, LED, PCB, if i dont know those then i have no business looking at this project. But seriously, thanks again for the help and ill let u know if i have any more questions.
Miltron_B (author)  handyScrapper6 years ago
Lolz! sry.. I wanted to leave no room for doubt. And yeah, It is damn expensive. Come to me when you start what ever when you have any trouble. Which you will. Cheers.
theophilus6 years ago
I wonder if you can replace it with a paintball gun?
( that +gocart+plexiglass+plywood=paintball tank!
I'm scaring myself, cool instructable!!!!!!!!!!!
thats was my first thought when seeing this. and its totally the same principle as long as you have a electronic gun.
Miltron_B (author)  Jfaranda76 years ago
I want to build a Small Robotic BB Tank. Though something you can actually ride is WAY better.
Miltron_B (author)  theophilus6 years ago
Yeah! You can. Just make sure your servos have enough torque to move it!
and you will need an electronic gun
Vittorio886 years ago
HAHAHA pinche hector nunca pense que te iba a ver aqui! Ah huevo cabron te felicito!
Miltron_B (author)  Vittorio886 years ago
A huevo mi Vic!!! Hahaha, como fuiste a dar por estos rumbos?? hack-A-Day?? Esa madre nunca la hubiera acabado sin los breaks de fumar con ustedes y con la ayuda del pinche Jonas. Un Abrazo muy fuerte desde aca, hermano. Urge que nos juntemos a quemar.
devin06 years ago
Awesome tutorial, is there a way I could do this but with a basic stamp microcontroller connected to PC by serial instead of using phidgets? I already have a basic stamp so I was wondering if there was a way use it instead.
Miltron_B (author)  devin06 years ago
Yes there is. Use the outputs of the BASIC to fire a relay circuit. Do that for the LEDs, Lasers and Guns. The Servo's can be controlled using the PWM feaure of the Stamp uC. Connect the signal (white or yellow) wire of the servo to the PWM output of your stamp uC and use the standard Hobby Servo Frequencies to drive them (Period is 2 ms). The Visual recognition is done in C, with the OpenCV libs. Have the C code write intro a file and the Stamp code read of it. There are other ways to integrate these two though...
Eres un pinche genio cabron!
Miltron_B (author)  aficiomaquinas6 years ago
Haha, gracias carnal. Me pare un hombros de gigantes.
zjharva6 years ago
lol! "warning! I don't know if this i dangerous!" nice instructable!
Miltron_B (author)  zjharva6 years ago
Hahaha, yeah. Sometimes one just has to take risks. Is it though?
PKM Miltron_B6 years ago
That depends on your definition of "dangerous". I think lasers are physically sensitive so if you are rough you might break the laser diodes, but it's not overly dangerous to you, other than maybe sharp bits of casing in your eyes. Wear goggles when dremelling!
=SMART=6 years ago
wow great ible, that thing looks dangerous !! lol
you should add high powered IR leds that way the with the cameras you can see at night. also i would have put the gun upside down so i could hang it on the over hang of my garage so i could shoot the pizza man as he gets back in to his car.
Miltron_B (author)  somerockenguy6 years ago
Hahaha, thanks dude. You say that by just adding a sort of lamp made IR LEDs it'll create a large enough refelction for the cameras to see at night? It might be worth trying out.
ya just take like 12 IR leds and wire them together. you could probaly assign a button on the controler to turn them on and off. if you do put them on though use the high powered ir leds through the cam it will look like it does during the day except in gray tone. one thing about the high powered ones it you can see a faint red glow but its not enough to make people know whats there. alson use resistores so you don't blow the ir leds there a little too expencive to be replacing every week(about $2 each). i use this site for figuring out what type of resistors to use. http://led. linear1 .org/led.wiz (remove spaces)
Miltron_B (author)  somerockenguy6 years ago
I'll give it a go when I have the chance. To calculate I just use Ohm's Law with the source voltage and the rated specs of the diode, makes it easier when you are out buying stuff.
A.C.E.6 years ago
im going to take my jacked up ak 47 airsoft gun and mount it on a tripod then bring it to life with my lego mindstorms nxt kit. by jacked up i mean 380 round hi-cap clip, 18 rounds per second (im guessing, probable more) an exploded stock when i meleed a tree (accident) and a hackjob exposed wiring sysem that came with putting in an aftermarket battery with twice as much voltage and mah. 9 or 10 volts and like 5600 mah or something like that. the battery that used to be in the stoc is now ducktaped to the side of the gun. untill it dies this instructable sounds pretty cool. vote : )
Miltron_B (author)  A.C.E.6 years ago
Post some pics when you do.
IX Smith XI6 years ago
You should add a video of it working dude. Good Instructable!
Miltron_B (author)  IX Smith XI6 years ago
Thanks! Currently I'm outside the continent, far from my beloved Mexico. But I will as soon as I get back home late in the year.
evanwehrer6 years ago
THIS IS AWESOME too bad its probably expensive to build
Miltron_B (author)  evanwehrer6 years ago
Thanks mate, glad you liked it. Unfortunately, it is expensive to build. Servos and the phidgets take quite a toll. But you can savage pretty much the rest of it. Plexiglas and wood are every where and the I'm sure if you as around you'll find your cameras and gun. You can make a really simple one that uses no Xbox controller or face recognition and make it with a uC! it'll be around $50 to build. This one costs around $300 to make.
A.C.E.6 years ago
lol the smiley broke