/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo myservo1;
Servo myservo2; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 90;
int pos2 = 90;
void setup()
{
Serial.begin(115200);
pinMode(2, INPUT);
myservo1.attach(9);
myservo2.attach(6);
}
void loop() {
if (digitalRead (2) == HIGH) {
for (pos = 0; pos <= 80; pos ++) {
for (pos2 = 60; pos2 >= 0; pos2 --)
{
Serial.print("1 pos: ");
Serial.print(pos);
Serial.print(" pos2: ");
Serial.println(pos2);
myservo1.write(pos);
myservo2.write(pos2);
delay(40);
}
for (pos = 0; pos <= 40; pos += 1) {
Serial.print("2 pos: ");
Serial.print(pos);
Serial.print(" pos2: ");
Serial.println(pos2);
myservo2.write(pos);
delay(80);
}
}
}
}