from machine import Pin
from time import sleep
motor_izqA = Pin(14, Pin.OUT)
motor_izqB = Pin(12, Pin.OUT)
motor_derA = Pin(15, Pin.OUT)
motor_derB = Pin(13, Pin.OUT)
#Las señales de los sensores son 1 para detectar y 0 para no detectar, corte binario
sensor_i = Pin(10, Pin.IN)
sensor_d = Pin(9, Pin.IN)
#Funciones Trigonometricas Terminadas
def avanzar(tiempo):
motor_izqA.on
motor_izqB.off
motor_derA.on
motor_derB.off
sleep(tiempo)
return
def detener(tiempo):
motor_izqA.off
motor_izqB.off
motor_derA.off
motor_derB.off
sleep(tiempo)
return
def izquierda(tiempo):
motor_izqA.off
motor_izqB.off
motor_derA.on
motor_derB.off
sleep(tiempo)
return
def derecha(tiempo):
motor_izqA.on
motor_izqB.off
motor_derA.off
motor_derB.off
sleep(tiempo)
return
#LOGITECH
while True:
lec_i=sensor_i.value()
lec_d=sensor_d.value()
if lec_i==0 and lec_d==0:
avanzar(0.2)
elif lec_i==1 and lec_d==0:
izquierda(0.2)
elif lec_i==0 and lec_d==1:
derecha(0.2)