Introduction: 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
1.Arduino uno or msp430 or any micro controller with serial communication facility
2.MATLAB
3. ARDUINO IDE
4. SERVO motors(positional control)X2
5.servo mounts and ply woods
6. WEBCAM
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
do it as shown in the image

Participated in the
Apocalypse Preparedness Contest

Participated in the
Automation Contest
8 Comments
6 years ago
nice da
7 years ago
great idea
8 years ago on Introduction
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.
Reply 8 years ago on Introduction
i have uploaded the new program check that .....:)
Reply 8 years ago on Introduction
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.
Reply 8 years ago on Introduction
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)
3.it 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
8 years ago on Introduction
Really cool idea! How long did this take you to design and make?
Reply 8 years ago on Introduction
this was my mini project (for b tech mechatronics). it took around 1 month . the though part was its calibration