/* 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>
#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN 2
Servo myservo1; // create servo object to control a servo
Servo myservo2;
// twelve servo objects can be created on most boards
int pos1 = 0; // variable to store the servo position
int pos2 = 180;
void setup() {
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(3);
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
}
void loop() {
int vert = analogRead(VERT_PIN);
int horz = analogRead(HORZ_PIN);
bool selPressed = digitalRead(SEL_PIN) == LOW;
if (vert>1000){
for (pos1 = 0; pos1 <= 180; pos1 += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo1.write(pos1); // tell servo to go to position in variable 'pos'
delay(1); // waits 15ms for the servo to reach the position
}
for (pos1 = 180; pos1 >= 0; pos1 -= 1) { // goes from 180 degrees to 0 degrees
myservo1.write(pos1); // tell servo to go to position in variable 'pos'
delay(1); // waits 15ms for the servo to reach the position
}
for (pos2 = 0; pos2 <= 180; pos2 += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo2.write(pos2); // tell servo to go to position in variable 'pos'
delay(1); // waits 15ms for the servo to reach the position
}
for (pos2 = 180; pos2 >= 0; pos2 -= 1) { // goes from 180 degrees to 0 degrees
myservo2.write(pos2); // tell servo to go to position in variable 'pos'
delay(1); // waits 15ms for the servo to reach the position
}
}
}