Robotic Arm

by ja634se in Circuits > Arduino

897 Views, 3 Favorites, 0 Comments

Robotic Arm

snip robot.PNG

this is my code so what i did was just duplacate a lot of the code 4 times because i used 4 servo motors and i used 2 diffrent joysticks soi just put 2 servos on there own x and y axis

//add theservo library
#include

//define our servos Servo Servo1; Servo Servo2; Servo Servo3; Servo Servo4; //define joystick pins (analog)

int joyX = A0; int joyY = A1; int joyX2 = A2; int joyY2 = A3; int switchstate; int pos=0; int joyVal; int joyVal2; int joyVal3; int joyVal4;

void setup() {

Servo1.attach(9); Servo2.attach(8); Servo3.attach(7); Servo4.attach(6);

}

void loop() {

joyVal = analogRead(joyY); joyVal = map (joyVal,0, 1023, 0, 180); Servo2.write(joyVal);

joyVal2 = analogRead(joyX); joyVal2 = map (joyVal2,0, 1023, 0, 180); Servo1.write(joyVal2);

joyVal3 = analogRead(joyX2); joyVal3 = map (joyVal3,0, 1023, 0, 180); Servo3.write(joyVal3);

joyVal4 = analogRead(joyY2); joyVal4 = map (joyVal4,0, 1023, 0, 180); Servo4.write(joyVal4);

Supplies

4 servo motors 2 joysticks an Arduino a bread bored 20 wires and any materials to make the robots frame

Wiring

20201110_095922.jpg

the wiring on this project was a pretty big problem i had a LOT of this to connect to the Arduino so I would recommend also picking up some zip ties so you can keep your wiring a little more organized