Rotating Turret Controlled by Arduino, by James Ackerman, Jacob Harmon and William Farr

by PHS_Engineering in Circuits > Arduino

31 Views, 0 Favorites, 0 Comments

Rotating Turret Controlled by Arduino, by James Ackerman, Jacob Harmon and William Farr

unnamed.jpg
James Jacob William arduino project 2024

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

unnamed.jpg

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

unnamed.jpg
unnamed.jpg

Attach 3 inch standoffs to each corner of the 5 x 25 Base plate using screws.

Frame Step 2

unnamed.jpg
unnamed.jpg

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

unnamed.jpg
unnamed.jpg

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

unnamed.jpg

Take the body off a toy gun.

Frame Step 5

unnamed.jpg
unnamed.jpg

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

unnamed.jpg
unnamed.jpg
unnamed.jpg

Attach the 3 sided 5 x 4 Base plate to the 5 x 25 Base plate.

Circuit Step 1

unnamed.jpg
unnamed.jpg
unnamed.jpg

Attach 8 round-point wires to the breadboard and arduino board.

Circuit Step 2

unnamed.jpg
unnamed.jpg
unnamed.jpg

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);

}