print("Moviendo Servo")
from machine import Pin, ADC, PWM
import time
pot = ADC(Pin(34))
pot.atten(ADC.ATTN_11DB)
pot.width(ADC.WIDTH_10BIT)
servo = PWM(Pin(13), freq=50)
# Nombre corregido de la función
def map_pot_to_servo(val):
min_duty = 26
max_duty = 128
return int(min_duty + (val / 1023) * (max_duty - min_duty))
while True:
pot_value = pot.read() # Cambio a 'pot_value' para evitar confusión
duty = map_pot_to_servo(pot_value) # Ahora usa el nombre correcto de la función
servo.duty(duty)
time.sleep(0.05)