Rotating Turret Controlled by Arduino, by James Ackerman, Jacob Harmon and William Farr
by PHS_Engineering in Circuits > Arduino
103 Views, 0 Favorites, 0 Comments
Rotating Turret Controlled by Arduino, by James Ackerman, Jacob Harmon and William Farr
Our project is a toy gun with a turret that rotates 60 degrees. You can rotate the turret by spinning the wheel. The gun fires through Arduino.
Supplies
Arduino Board
2 inch axel
3 inch axel
Baring Block
5 x 25 Base plate
5 x 4 3 sided bent Base plate
5 x 5 Base plate
Breadboard
Button
Collar
Funnel
(1/4 inch motor screw) x2
(Nut) x6
Potentiometer
Power source(Laptop)
(Round-point wire) x8
Rubber collar
(1/4 inch screw) x4
(1/2 inch screw) x6
(1 inch screw) x2
1.5 inch screw
Servo Motor
24 tooth sprocket
1 inch standoff
(3 inch standoff) x4
Toy Gun
USB
Wheel
Frame Step 1
Attach 3 inch standoffs to each corner of the 5 x 25 Base plate using screws.
Frame Step 2
Attach a Servo Motor to base plate using motor screws. Attach a baring block to the motor screws with 2 1/2 inch screws.
Frame Step 3
Attach a 2 inch axel and put a rubber collar and a 24 tooth sprocket on top. Put a 5 x 5 Base plate then a 3 sided 5 x 4 Base plate. Connect the two Base plates together with 1/4 inch screws in the corners with 1 inch screws in the middle going through the sprocket. Put nuts on the end of each screw, place a collar on top of the axel.
Frame Step 4
Take the body off a toy gun.
Frame Step 5
Attach the gun to the 3 sided 5 x 4 Base plate, Attach a collar on the other end of the axel to hold it in place.
Frame Step 6
Attach the 3 sided 5 x 4 Base plate to the 5 x 25 Base plate.
Circuit Step 1
Attach 8 round-point wires to the breadboard and arduino board.
Circuit Step 2
Attach the Servo Motor to the Breadboard. Attach a potentiometer with a 3 inch axel, rubber collar and a wheel on top to the bredboard
Code
#include <Servo.h>
// HERE BE DRAGONS. When we ran this code in 2024, there was difficulty with the servo and potentiometer, we never figured out if it was a coding issue or a mechanical issue. be weary when copying this design.
// YOU HAVE BEEN WARNED
Servo myServo;
int potPin = A1; //Pin potentiometer is mapped to
int servoPin = 10; //Pin servo is mapped to
int potValue; //identifies the output value of the potentiometer
int servoAngle; //identifies servo angle
void setup() {
//Put your setup code here, to run once:
myServo.attach(servoPin);
Serial.begin(9600);
}
void loop() {
//Put your main code here, to run repeatedly:
potValue = analogRead(potPin); //sets the value of the Potentiometer to the output value given by the potentiometer pin, between 0-1023
servoAngle = map(potValue, 0, 1023, 0, 180); //maps potentiometers highest and lowest values, from 0 to 180 degrees of rotation for servo angle
myServo.write(servoAngle); //maps rotation of servo to output value of potentiometer (1023/x degree of rotation = servo turn value)
delay(250);
Serial.print("potValue = ");
Serial.print(potValue);
Serial.print(", servoAngle = ");
Serial.println(servoAngle);
//prints output value of servo and potentiometer to monitor in case of bugs
delay(5);
}