from machine import Pin
from time import sleep
from servo import Servo # usa tu servo.py
# Pines
SERVO1_PIN = 18
SERVO2_PIN = 19
BUTTON_PIN = 32
# Objetos
s1 = Servo(Pin(SERVO1_PIN))
s2 = Servo(Pin(SERVO2_PIN))
button = Pin(BUTTON_PIN, Pin.IN, Pin.PULL_UP)
# Posiciones iniciales
pos = 0
while True:
if button.value() == 0: # botón presionado (LOW)
pos = 180 if pos == 0 else 0
s1.write_angle(degrees=pos)
s2.write_angle(degrees=pos)
sleep(0.3) # pausa corta para evitar que se dispare demasiadas veces