# L11 - program receptie comenzi stanga/dreapta/inainte # de la pagina web penru control video. # Conexiuni modul BT: # Rx - pin 7 # Tx - pin 6 #Conexiuni motoare # md GP16 pin 21 -motor dreapta # ms GP15 pin 20 -motor stanga #Conexiuni led-uri # red GP6 pin 9 # blue GP7 pin 10 # amber GP8 pin 11 from machine import Pin, Timer,UART,PWM import time import _thread ser=UART(1,9600) fan=_thread.allocate_lock() # fanion mutex md=Pin(16, Pin.OUT) ms=Pin(15, Pin.OUT) s1=Timer() led=Pin(25,Pin.OUT) red=Pin(6, Pin.OUT) blue=Pin(7, Pin.OUT) amber=Pin(8, Pin.OUT) ird = Pin(13, Pin.IN, Pin.PULL_UP) irm = Pin(12, Pin.IN, Pin.PULL_UP) irs = Pin(11, Pin.IN, Pin.PULL_UP) red.high() # stare initiala blue.high() amber.high() t=0.02 # durata activitate motoare def mdgo(): # activez motor dreapta amber.low() md.high() time.sleep(t) md.low() amber.high() def msgo(): # acivez motor stanga red.low() ms.high() time.sleep(t) ms.low() red.high() def mdmsgo(): # ambele motoare activate blue.low() md.high() ms.high() time.sleep(t) md.low() ms.low() blue.high() #s1.init(freq=10, mode=Timer.PERIODIC, callback=bl) def blk(): # semnalizare program activ while 1: fan.acquire() led.high() time.sleep(0.2) led.low() time.sleep(0.2) fan.release() _thread.start_new_thread(blk,()) while 1: c=ser.read(1) #print(c) # pentru faza test if c == b'1': # virare catre stanga mdgo() # if c == b'2': # deplasare inainte mdmsgo() if c == b'3': # virare catre dreapata msgo() time.sleep(0.1) # inertie