from machine import Pin, PWM
import time
# Define los ángulos y los ciclos de trabajo correspondientes
angle_duty_map = {
0: 1638,
40: 3500,
120: 6000,
135: 7375,
}
servo1 = PWM(Pin(15))
servo1.freq(50)
boton0 = Pin(17, Pin.IN, Pin.PULL_DOWN)
boton40 = Pin(16, Pin.IN, Pin.PULL_DOWN)
while True:
if boton0.value() == 1:
servo1.duty_u16(angle_duty_map[0])
time.sleep(0.5)
if boton40.value() == 1:
servo1.duty_u16(angle_duty_map[40])
time.sleep(0.5)