Is it possible to run servo1 cw, while servo2 runs ccw ? Both should do the same angles.
#include <Servo.h>
byte buttonSw1 = 2;
byte buttonSw2 = 3;
byte buttonSw3 = 4;
Servo myservo1;
Servo myservo2;
int pos = 35; // variable to store the servo position
void setup()
{
myservo1.attach(9);// attaches the servo on pin 9 to the servo
myservo2.attach(10);
pinMode (buttonSw1, INPUT_PULLUP );
pinMode (buttonSw2, INPUT_PULLUP );
pinMode (buttonSw3, INPUT_PULLUP );
while (digitalRead (buttonSw1)) {}
Serial.println ("press the buttonSw1 (0)");
//end of setup
}
void loop() {
for (pos = 35; pos <= 100; pos += 1) {
myservo1.write(pos);
delay(15);
}
for (pos = 35; pos <= 100; pos += 1) {
myservo2.write(pos);
delay(15);
}
while (digitalRead(buttonSw2)){}
Serial.println("press the buttonSw2 to change direction");
for (pos = 100; pos >= 35; pos -= 1) {
myservo1.write(pos);
delay(15);
}
for (pos = 100; pos >= 35; pos -= 1) {
myservo2.write(pos);
delay(15);
}
while (digitalRead(buttonSw3)){}
Serial.println("press the buttonSw3 to change direction");
}