from machine import Pin, PWM
import time
# Configuración de pines para los interruptores y motores
muestra = Pin(5, Pin.IN)
chico = Pin(18, Pin.IN)
grande = Pin(19, Pin.IN)
stop = Pin(21, Pin.IN)
rodillo_ena = Pin(13)
rodillo_in1 = Pin(12, Pin.OUT)
#rodillo_in2 = Pin(14, Pin.OUT)
sellador_ena = Pin(27)
sellador_in1 = Pin(26, Pin.OUT)
sellador_in2 = Pin(25, Pin.OUT)
pwm_rodillo = PWM(rodillo_ena)
pwm_sellador = PWM(sellador_ena)
pwm_rodillo.duty(20)
pwm_sellador.duty(1000)
contador = 0
tiempo_muestra = 2
tiempo_chico = 4
tiempo_grande = 6
tiempo_sellado = 5
# Bucle principal
while True:
sw_muestra = muestra.value()
sw_chico = chico.value()
sw_grande = grande.value()
sw_stop = stop.value()
if sw_muestra == 1:
rodillo_in1.on()
time.sleep(tiempo_muestra)
rodillo_in1.off()
time.sleep(1)
sellador_in1.on()
time.sleep(1)
sellador_in1.off()
time.sleep(tiempo_sellado)
sellador_in2.on()
time.sleep(1)
sellador_in2.off()
time.sleep(2)
contador +=1
print(f"Muestras terminadas: {contador}")
elif sw_chico == 1:
rodillo_in1.on()
time.sleep(tiempo_chico)
rodillo_in1.off()
time.sleep(1)
sellador_in1.on()
time.sleep(1)
sellador_in1.off()
time.sleep(tiempo_sellado)
sellador_in2.on()
time.sleep(1)
sellador_in2.off()
time.sleep(2)
contador +=1
print(f"Producto chico terminado: {contador}")
elif sw_grande == 1:
rodillo_in1.on()
time.sleep(tiempo_grande)
rodillo_in1.off()
time.sleep(1)
sellador_in1.on()
time.sleep(1)
sellador_in1.off()
time.sleep(tiempo_sellado)
sellador_in2.on()
time.sleep(1)
sellador_in2.off()
time.sleep(2)
contador +=1
print(f"Producto grande terminado: {contador}")
if sw_stop == 1:
contador = 0
break