Introduction: Self Aiming and Engaging Gun

Picture of Self Aiming and Engaging Gun

This is controlled by image processing method for finding and eliminating human moving in front of the camera.
this can be used for

pinball gun

paint gun laser

tag gun

i am going to use laser just to demonstrate . u can use anything

Step 1:

Step 2: Parts

Picture of Parts

1.Arduino uno or msp430 or any micro controller with serial communication facility



4. SERVO motors(positional control)X2

5.servo mounts and ply woods


7. small laser pointer (or) electrically operated pain ball gun etc

Step 3: Uploading Msp430 Program (energia)

energia is same as arduino ide. this program can also be used for arduino uno(you just have to change the pin numbers that all it needs).

connect the board to your computer and click upload

that's it

i have uploaded the edited version of the matlab code in this pro.rar file

Step 4: Image Processing

open matlab software

browse to the downloaded file and load the checksent.m file

change the webcam number to yours

line no 3 = change the webcam number if you are using 2 or more webcam simultaneously

(vid = videoinput('winvideo',1);)

line no 8= change the com port number to your needed com port

(s = serial('COM4','BaudRate',9600);)

click play

Step 5: Calibration

this is the though job . i had given you the values for an 7 feet room . in case if you are using this mechanism for a different sized room you have to find the angle for the ground and top servo (enter a new angle and check where the laser hit, then find the distance between the points and change the angle to reach your point are the center of the box)..... just an hour or two will be enough for finding and updating these values .

Step 6: Fitting

Picture of Fitting

do it as shown in the image


ChandraM19 (author)2016-07-14

nice da

pj200 (author)2015-11-29

great idea

vu2aeo (author)2015-04-01

Nice project, but I think it would have helped if you explain the parts of your matlab code better, so that someone reading this could understand it and learn from your code rather than just "copy pasting" it.

ysingh7 (author)vu2aeo2015-04-02

i have uploaded the new program check that .....:)

vu2aeo (author)ysingh72015-04-02

After having gone through your code I find several inconsistencies....

1. You are connecting one servo to pin 8 which is NOT a PWM pin. How are you doing this?

2. After image processing in matlab, you seem to be sending only one value = 'y' to the serial interface, and you therefore have two servos only one of which is actually tracking. Not very efficient use of hardware.

3. You method of decoding the incoming data on the arduino is extremely cumbersome, uses too much memory and demonstrates poor programming practice. Instead of making a hundred possible if statements and comparing integer a with 'A' then 'B' then 'C' etc etc, you could have done it all in just one single line like

Servo2.write(a - 3 + some_throwoff_value);

In my opinion, this project is still very nascent, not yet at a presentable stage. You could try and implement 2 - axis tracking (very easy with your hardware), a kalman filter for better tracking (and noise reduction) of the moving object (a little harder), and perhaps your demo video could show how exactly the laser was tracking the target. In this video, we can only see the servos moving and no actual tracking at all. So I hope you will improve your code a little more, there is much promise in this project, but still a long way to go.

ysingh7 (author)vu2aeo2015-04-02

1.all the digital pin in arduino is capable of driving servo motors(no pwm pin is required)because the servo library uses timer program not pwm program... u can check this by connecting a servo and run it

2.after a lot of calibration ,i find out that the center of mass so most of the human target (while standing). lies in a specific line ,so i thought it would be easy to fix one servo and move another one (not the best method for a complete system) will be very helpful is u send me some example codes for that ... i have no idea on how to do that

4. i will improve this project soon

tomatoskins (author)2015-03-24

Really cool idea! How long did this take you to design and make?

ysingh7 (author)tomatoskins2015-03-25

this was my mini project (for b tech mechatronics). it took around 1 month . the though part was its calibration