# Program generare conditii de miscare # prin activare electromagneti cu Pico si LM298 # Comexiuni: # ena - GP15 # in1 - GP14 # in2 - GP16 # enb - GP11 # in3 - GP13 # in4 - GP12 # sensor hall 3 - GP8 # sensor hall 4 - GP 7 # Driverul ST 298 are conectate la intrarile in1-in4 LED-uri cu catodul # la masa si rezistente de , deci se aprind in 1 logic. # Daca sunt corecte conexiunile cele 4 LED-uri de pe driverul ST sunt activate/dezactivate import machine # clase pentru componente hardware import time # clasic , eventual utime amber=machine.Pin(18, machine.Pin.OUT) #LED general p=machine.ADC(27) # potentiometru control viteza ena=machine.Pin(15, machine.Pin.OUT) in1=machine.Pin(14, machine.Pin.OUT) in2=machine.Pin(16, machine.Pin.OUT) enb=machine.Pin(11, machine.Pin.OUT) in3=machine.Pin(13, machine.Pin.OUT) in4=machine.Pin(12, machine.Pin.OUT) hall1=machine.Pin(10, machine.Pin.IN, machine.Pin.PULL_UP) # senzor hall dreapta hall2=machine.Pin(9,machine.Pin.IN, machine.Pin.PULL_UP) # sensor hall stanga hall3=machine.Pin(8, machine.Pin.IN, machine.Pin.PULL_UP) # senzor hall dreapta hall4=machine.Pin(7,machine.Pin.IN, machine.Pin.PULL_UP) # sensor hall stanga def atrag1(pin): # activez curent sens 1 in1.high() in2.low() ena.high() # activare intrari time.sleep(0.2) ena.low() # desactivez intari def atrag2(pin): # activez curent sens 1 in3.high() in4.low() enb.high() # activare intrari time.sleep(0.2) enb.low() # desactivez intari def resping1(pin): # activez curent sens 2 in1.low() in2.high() ena.high() # activare intrari time.sleep(0.2) ena.low() # desacyivez intari def resping2(pin): # activez curent sens 2 in3.low() in4.high() enb.high() # activare intrari time.sleep(0.2) enb.low() # desacyivez intari t=0.2 t1=0,05 ena.low() # initializare driver enb.low() #hall1.irq(trigger=machine.Pin.IRQ_FALLING, handler =atrag1) hall2.irq(trigger=machine.Pin.IRQ_FALLING, handler =resping1) #hall3.irq(trigger=machine.Pin.IRQ_FALLING, handler =atrag2) hall4.irq(trigger=machine.Pin.IRQ_FALLING, handler =resping2) while 1 : amber.low() time.sleep(0.1) amber.high() time.sleep(0.1) #print(p.read_u16())