#include <Servo.h>
const int PIN_SERVO = 9;
const int PIN_POT = A0;
Servo miServo;
void setup() {
Serial.begin(9600);
miServo.attach(PIN_SERVO);
}
void loop() {
int lectura = analogRead(PIN_POT);
// Traduce la posición del potenciómetro a un ángulo de 0 a 180 grados
int angulo = map(lectura, 0, 1023, 0, 180);
miServo.write(angulo);
Serial.print("Lectura: ");
Serial.print(lectura);
Serial.print(" -> Ángulo: ");
Serial.println(angulo);
delay(50);
}