#include <Servo.h>
//This initializes the objects/ pins for the 2 servos controlling the top
Servo servo_t1;
Servo servo_t2;
const int top[2] = {3,9};
//This initializes the objects/ pins for the 2 servos controlling the bottom
Servo servo_b1;
Servo servo_b2;
const int bottom[2] = {5,6};
void setup() {
//This initializes the pins for the 2 servos controlling the top
servo_t1.attach(top[0]);
servo_t2.attach(top[1]);
//This initializes the pins for the 2 servos controlling the bottom
servo_b1.attach(bottom[0]);
servo_b2.attach(bottom[1]);
pinMode(A7, INPUT);//This is the Right slider
pinMode(A6, INPUT); //This is the Left Slider
pinMode(12, INPUT); //This is the swtich that'll turn the servos on or off through software
}
void loop() {
unsigned int slider_t = analogRead(A7);
unsigned int slider_b = analogRead(A6);
//Map the values from 1023 (the full range of the slider) to 90
int top_claw = map(slider_t, 0, 1023, 0, 90); //Map the values from 1023 (the full range of the slider) to 90
int bottom_claw = map(slider_b, 0, 1023, 0, 90);
//Move the top servos (claw-style)
servo_t1.write(top_claw);
servo_t2.write((180-top_claw));
//Move the bottom servos (claw-style)
servo_b1.write(bottom_claw);
servo_b2.write((180-bottom_claw));
}