#include <Servo.h>
Servo base; //Declare the base to a servo, potentiometer, the digital pin for the pwm, and the value for translation
const int basepot =A0;
const int basepin = 9;
int basevalue;
Servo elbow; //Declare the elbow to a servo, potentiometer, the digital pin for the pwm, and the value for translation
const int elbowpot =A1;
const int elbowpin = 3;
int elbowvalue;
Servo pivot; //Declare the pivot to a servo, potentiometer, the digital pin for the pwm, and the value for translation
const int pivotpot = A2;
const int pivotpin = 5;
int pivotvalue;
Servo grip; //Declare the gripper to a servo, potentiometer, the digital pin for the pwm, and the value for translation
const int grippot = A3;
const int grippin = 6;
int gripvalue;
void setup() {
//attach the servos into the pins assigned
base.attach(basepin);
elbow.attach(elbowpin);
pivot.attach(pivotpin);
grip.attach(grippin);
}
void loop() {
//upon translating potentiometer value into a value that the servo can read, the servo will write the value
basevalue = analogRead(basepot);
basevalue = map(basevalue, 0, 1023, 0, 180);
base.write(basevalue);
elbowvalue = analogRead(elbowpot);
elbowvalue = map(elbowvalue, 0, 1023, 0, 180);
elbow.write(elbowvalue);
pivotvalue = analogRead(pivotpot);
pivotvalue = map(pivotvalue, 0, 1023, 0, 180);
pivot.write(pivotvalue);
gripvalue = analogRead(grippot);
gripvalue = map(gripvalue, 0, 1023, 0, 180);
grip.write(gripvalue);
delay(5);
}