2024-12-03 16:31:00 +01:00
|
|
|
#include <Servo.h>
|
2024-12-03 16:59:21 +01:00
|
|
|
Servo servo1;
|
|
|
|
int const potPin1 = A0;
|
|
|
|
Servo servo2;
|
|
|
|
int const potPin2 = A1;
|
2024-12-03 16:31:00 +01:00
|
|
|
int potVal;
|
|
|
|
int angle;
|
|
|
|
|
|
|
|
void setup() {
|
2024-12-03 16:59:21 +01:00
|
|
|
servo1.attach(8);
|
|
|
|
servo2.attach(9);
|
2024-12-03 16:31:00 +01:00
|
|
|
|
|
|
|
Serial.begin(9600);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2024-12-03 16:59:21 +01:00
|
|
|
potVal = analogRead(potPin1);
|
2024-12-03 16:31:00 +01:00
|
|
|
angle = map(potVal, 0, 1023, 0, 179);
|
2024-12-03 16:59:21 +01:00
|
|
|
servo1.write(angle);
|
|
|
|
Serial.print("Potval1: ");
|
2024-12-03 16:31:00 +01:00
|
|
|
Serial.print(potVal);
|
2024-12-03 16:59:21 +01:00
|
|
|
|
|
|
|
potVal = analogRead(potPin2);
|
|
|
|
angle = map(potVal, 0, 1023, 0, 179);
|
|
|
|
servo2.write(angle);
|
|
|
|
Serial.print("Potval2: ");
|
|
|
|
Serial.print(potVal);
|
|
|
|
|
2024-12-03 16:31:00 +01:00
|
|
|
Serial.print(" Angle: ");
|
|
|
|
Serial.print(angle);
|
|
|
|
|
|
|
|
delay(15);
|
|
|
|
}
|