Aggiunto il supporto per il joycon

This commit is contained in:
KillerBossOriginal 2024-12-03 16:59:21 +01:00
parent 5cb4ca8b7f
commit 767fd193c3

View file

@ -1,25 +1,33 @@
#include <Servo.h> #include <Servo.h>
Servo myServo; Servo servo1;
int const potPin = A0; int const potPin1 = A0;
Servo servo2;
int const potPin2 = A1;
int potVal; int potVal;
int angle; int angle;
void setup() { void setup() {
myServo.attach(8); servo1.attach(8);
servo2.attach(9);
Serial.begin(9600); Serial.begin(9600);
} }
void loop() { void loop() {
potVal = analogRead(potPin); potVal = analogRead(potPin1);
angle = map(potVal, 0, 1023, 0, 179); angle = map(potVal, 0, 1023, 0, 179);
servo1.write(angle);
Serial.print("Potval: "); Serial.print("Potval1: ");
Serial.print(potVal); 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: ");
Serial.print(angle); Serial.print(angle);
myServo.write(angle);
delay(15); delay(15);
} }