33 lines
579 B
C++
33 lines
579 B
C++
#include <Servo.h>
|
|
Servo servo1;
|
|
int const potPin1 = A0;
|
|
Servo servo2;
|
|
int const potPin2 = A1;
|
|
int potVal;
|
|
int angle;
|
|
|
|
void setup() {
|
|
servo1.attach(8);
|
|
servo2.attach(9);
|
|
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
void loop() {
|
|
potVal = analogRead(potPin1);
|
|
angle = map(potVal, 0, 1023, 0, 179);
|
|
servo1.write(angle);
|
|
Serial.print("Potval1: ");
|
|
Serial.print(potVal);
|
|
|
|
potVal = analogRead(potPin2);
|
|
angle = map(potVal, 0, 1023, 0, 179);
|
|
servo2.write(angle);
|
|
Serial.print("Potval2: ");
|
|
Serial.print(potVal);
|
|
|
|
Serial.print(" Angle: ");
|
|
Serial.print(angle);
|
|
|
|
delay(15);
|
|
}
|