/*
Servo_Test.ino
Brown Dog Gadgets <https://www.browndoggadgets.com/>
*/
#include <Servo.h>
Servo horizontal;
Servo vertical;
int pos = 0;
int moveDelay = 50;
int potValue;
int mapValue;
void setup() {
Serial.begin(9600);
horizontal.attach(5);
vertical.attach(6);
horizontal.write(90);
vertical.write(90);
delay(1000);
}
void loop() {
potValue = analogRead(A0);
mapValue = map(potValue, 0, 1023, 0, 180);
horizontal.write(mapValue);
Serial.print("potValue: "); Serial.println(potValue);
Serial.print("mapValue: "); Serial.println(mapValue);
delay(200);
/*
for (pos = 0; pos <= 180; pos++) {
horizontal.write(pos);
delay(moveDelay);
}
delay(1000);
for (pos = 180; pos >= 0; pos--) {
horizontal.write(pos);
delay(moveDelay);
}
delay(1000);
for (pos = 0; pos <= 180; pos++) {
vertical.write(pos);
delay(moveDelay);
}
delay(1000);
for (pos = 180; pos >= 0; pos--) {
vertical.write(pos);
delay(moveDelay);
}
delay(1000);
*/
}