Death Machine Final Evolution
Duncan Miller
Brian Moore
Description
Death Machine Final Evolution is the epitome of a home security device (with limitless applications). The latest in a series of Arduino programmed pojectile launchers, Death Machine F.E. fuses a trio of servo motors, a Nerf gun, and a makeshift control panel (two potentiometers and a push button) to ultimately perfect a pennetrating application of engineering technology. Mounting a Nerf sniper rifle on a rotating platform (bolted to a tripod) allows for a two dimensional rotational axis of over 100 degrees. This base motor is synched with a corresponding potentiometer for user control. A second servo motor was tied to one end of the platform, enabling the gun to adjust vertically for an optimal aiming experience. This servo is similarly linked to a potentiometer. The final trigger servo employs hybrid programing for an clean, smooth shot.
Program Description
After declaring the integers to be used and setting up the void servoPulses for the three servo motors, this section of the programing deals with the trigger servo and its accompanying push button. At rest, the trigger finger is stationed at 30 degrees. When the button is pushed, the motor will turn sixty degrees. The for loop is necessary so that the user need not hold down the button (one simple push is more convenient). After the stationed servo turns, thereby pulling the trigger, it will return to its starting position of 30 degrees and is ready to fire again after the gun has been recocked.
void loop()
{
val = digitalRead (button); //Sets 'val' equal to the input pin (high or low)
if (val==HIGH) { //If the button is pushed, move the servo
for (int x = 0; x <=50; x++) //Declares x, tests if less than 50, increments x by 1
{
myAngle = 90; //Sets myAngle to 90 degrees when push button
servoPulse (trigger, myAngle); //Sets pin and angle for servoPulse void
delay (20); //Refreshes cycle
}
}
else { //If val is not HIGH
myAngle = 30; //Sets myAngle to initial position of 30 degrees
servoPulse (trigger, myAngle); //Sets pin and angle for servoPuse void
delay (20); //Refreshes cycle
}
This next part is used to control the spinning base motor. The servo is positioned under the tripod and attached to the rotating base. It is mapped with the corresponding potentiometer. Turning the knob on the potentiometer spins the servo and, thus, points the gun in the intended direction.
valb=analogRead(potb); //Sets 'valb' equal to the state of the base potentiometer
valb=map(valb,0,1023,0,179); //Equates the base potentiometer read with corresponding //base angle
baseAngle=valb; //Sets the baseAngle to mapped degree for the base
servoPulseb(base,baseAngle); //Sets pin and angle for servoPulseb void
delay(20); //Refreshes cycle
This final excerpt deals with the vertical servo motor that elevates or lowers the gun for higher targets and peak range. It works similar to the base servo except for the map. We had to adjust it so it could not rotate the full 180 degrees (when it did, there would be no weight balance to lower it again). We found, using our adjustable mount, that a maximum of 75 degrees would allow the gun to lower back down to its starting position without intervention.
valv=analogRead(potv); //Sets 'valv' equal to the state of the vertical potentiometer
valv=map(valv,0,1023,0,75); //Equates the vertical potentiometer read with corresponding base angle (up to 75)
vertAngle=valv; //Sets the vertAngle to mapped degree for the vertical servo
servoPulsev(vert,vertAngle); //Sets pin and angle for servoPulseb void
delay(20); //Refreshes cycle
Pictures and Video
Complete Program
int trigger = 10; //Declares trigger servo connected to digital pin 2int myAngle; // angle of the trigger servo roughly 0-180int pulseWidth; // servoPulse function variable for the triggerint button = 3; // Connect push button (for the trigger) to pin 3 int val = 0; //Variable to store the read valueint base = 12; //Declares base servo connected to pin 12int baseAngle; //angle of the spinning base servo roughly 0-180int baseWidth; //servoPulseb function variable for the spinning base servoint valb; //Variable to store the analog read of the potentiometer for the baseint potb = 4; //Input pin for the base potentiometer in pin 4int valv; //Variable to store the analog read of the potentiometer for the vertical servoint potv = 1; //Input pin for the vertical potentiometer in pin 1int vert = 6; //Declares vertical servo connected to pin 6int vertAngle; //angle of the vertical servo roughly 0-180int vertWidth; //servoPulsev function variable for the vertical servovoid setup () { pinMode(trigger, OUTPUT); //sets pin 10 as output pinMode (base, OUTPUT); // sets pin 12 as output pinMode(button, INPUT); //sets pin 3 as input } void servoPulse(int trigger, int myAngle) { pulseWidth = (myAngle * 10) + 600; //Determines delay for trigger digitalWrite(trigger, HIGH); // Sets servo high delayMicroseconds(pulseWidth); //Microseconds of pause digitalWrite(trigger, LOW); //Sets servo as low } void servoPulseb(int base, int baseAngle) { baseWidth = (baseAngle * 10) + 600; //Determines delay for base servo digitalWrite(base, HIGH); // Sets servo high delayMicroseconds(baseWidth); //Microseconds of pause digitalWrite(base, LOW); //Sets servo as low } void servoPulsev (int vert, int vertAngle) { vertWidth = (vertAngle * 10) + 600; //Determines delay for vertical servo digitalWrite(vert, HIGH); // Sets servo high delayMicroseconds(vertWidth); //Microseconds of pause digitalWrite(vert, LOW); //Sets servo as low } void loop() { val = digitalRead (button); //Sets 'val' equal to the input pin (high or low) if (val==HIGH) { //If the button is pushed, move the servo for (int x = 0; x <=50; x++) //Declares x, tests if less than 50, increments x by 1 { myAngle = 90; //Sets myAngle to 90 degrees when push button servoPulse (trigger, myAngle); //Sets pin and angle for servoPulse void delay (20); //Refreshes cycle } } else { //If val is not HIGH myAngle = 30; //Sets myAngle to initial position of 30 degrees servoPulse (trigger, myAngle); //Sets pin and angle for servoPuse void delay (20); //Refreshes cycle } valb=analogRead(potb); //Sets 'valb' equal to the state of the base potentiometer valb=map(valb,0,1023,0,179); //Equates the base potentiometer read with corresponding //base angle baseAngle=valb; //Sets the baseAngle to mapped degree for the base servoPulseb(base,baseAngle); //Sets pin and angle for servoPulseb void delay(20); //Refreshes cycle valv=analogRead(potv); //Sets 'valv' equal to the state of the vertical potentiometer valv=map(valv,0,1023,0,75); //Equates the vertical potentiometer read with corresponding //base angle (up to 75) vertAngle=valv; //Sets the vertAngle to mapped degree for the vertical servo servoPulsev(vert,vertAngle); //Sets pin and angle for servoPulseb void delay(20); //Refreshes cycle }
Problems Encountered and Solved
A number of our problems were related to the engineering of the physical device and how it would be set up. What gun would we use? What would be our base for the gun? How would it rotate? How could we prevent the gun from sliding but still be able to lift it up to reload the clip? How could we maximize the turning power of the servos using as much leverage as possible? Could we make the board on which the gun is mounted adjustable? How could we get a trigger finger long enough to pull the button? How can we get a laser pointer onto the gun?
The two of us decided on a nerf sniper rifle with a two legged stand that would allow us to secure the gun to the board. We used a metal slate, tightened it above a notch in each front leg, and bolted it to the board. The gun can easily be removed unharmed by loosening the bolt.
We needed a board that could adjust how we needed it for leverage, depending on its final weight. We did not want it too heavy in front or the motor would not be strong enough to elevate it. If it was too heavy in the back, we would not be able to lower it as needed. It would not be as simple as adding weight on the opposite side because then the spinning motor would be difficult to rotate the gun. We decided on cutting out lengthy strip from the center of the board and using wing bolts to let us easily adjust the board forward or back for ideal leverage.
We settled on a common video tripod as the foundation for this device. It is simple, available, and works pretty smoothly. We had to fix it up a bit (the rotating top moved independent from the bottom where we intended to attach our base servo). The handle used for directing a camera also serves as a useful lever for the vertical servo, which needs all the leverage it can get to elevate the gun.
Another problem that we encountered was getting a servo to pull the trigger. At first, we could not find an easy solution to lengthening the servo's arm. Ultimately, we found a head that would work when angled correctly. Then it was just a matter of screwing one side into to a secured block of wood and lining up the gun. The hybrid program that we wrote lets the user push the button once (rather than hold it down) and makes the servo turn only a limited number of degrees to pull the trigger smoothly and effectively.
Another issue was where to position the two moving servo motors. The horizontal base servo, we found, would work perfectly with the bottom of the tripod's pole (the bottom of the metal stick from the top base continues down to the bottom). Taping the bottom of the hollow stick and hot gluing it to the servo motor allows for maximum surface area while not damaging the tripod. A solid hot glue job nicely attaches the servo (which is on a wood block to minimize friction on top). More difficult was the vertical motor. What we finally realized would work best is attaching the motor to the rotating stick as well, but halfway up the side. It moves when the base servo moves. In this way, we do not have to lengenth the vertical motor to allow the gun to spin (which we would if the servo was attached to a stationary point). Despite doubts, another convenient hot glue job is strong enough to hold it steady.
We had to be careful to position the spinning base servo exacly in the middle so that the vertical motor's string would not interfere with the legs. To do this, we had to used a serial.print (not included) to determine the exact center of the servo and then glued it right in the middle of the
We added on a laser pointer for easier aiming and to make it an authentic sniper.
In addition to these challenges, we also had few difficulties with some of the programming and electronic devices. Due to frustrating equipment, we had to switch Arduino processors. Also, with the jumbles of wires, we had diffiuclty determining if there was an error with the computer programming or simply missing resistors or a short circuit. Ultimately, we figured out all of the difficulties and programed the motors with poteniometers and the push button to do exacly as intended.
Potential Improvements
For use as a legitimate home security device, obviously a different launcher must be used. Ideally, something between a tranquilizer and an M40, but the most effective weapon would be heat seeking laser-guided rockets. But for obvious safety regulations and monetary purposes, we cannot provide any of those adaptions.
Given a larger budget, a stronger servo motor would be first. There was some difficulty getting the vertical motor to raise the nose of the gun. It most certainly does at the present but a stronger motor could increase the range of the angle, even allowing for a longer range. Also, we could use a 360 degree rotating servo on the base to get a full range of motion in any direction.
A more eye-pleasing control panel (something like a remote control) would be a good addition given more time or money. Ideally, we had intended to sync Death Machine with a Wii mote but the adapter never showed up in time so we had to make due with potentiometers and a button. Combining them all into a single, hand held device would make Death Machine even more user-friendly.