# Program activare transmisie la apasare buton # Pot fi utilizate microintrerupatoare k1, k2, k3 import nrf24l01 from machine import Pin, SPI import time led = machine.Pin("LED", machine.Pin.OUT) # led de pe placa, sau 25 la clasic spi = SPI(0, sck=Pin(2), mosi=Pin(3), miso=Pin(4)) nrf = nrf24l01.NRF24L01(spi, Pin(5), Pin(8), channel=108,payload_size=16) # canal mai liber nrf.set_power_speed(nrf24l01.POWER_2, nrf24l01.SPEED_250K) # propagare mai buna nrf.open_tx_pipe(b"Pico1") # IP al procesorului destinatie, byte string (max 5) nrf.start_listening() nrf.stop_listening() g=Pin(20,Pin.OUT) # led green activ cu 1 y=Pin(21,Pin.OUT) # led galben r=Pin(22,Pin.OUT) # led rosu k1=Pin(17, Pin.IN, Pin.PULL_UP) # buton verde k2=Pin(18, Pin.IN, Pin.PULL_UP) # buton galben k3=Pin(19, Pin.IN, Pin.PULL_UP) # buton rosu g.value(0) # initial stins y.value(0) r.value(0) def green(a): # handler buton verde #machine.disable_irq() g.value(1) time.sleep(0.1) g.value(0) nrf.send(b"0") #machine.enable_irq() def yellow(a): # handler buton galben y.value(1) time.sleep(0.1) y.value(0) nrf.send(b"1") def red(a): # handler buton rosu r.value(1) time.sleep(0.1) r.value(0) nrf.send(b"2") k1.irq(trigger=Pin.IRQ_FALLING, handler=green) # fara debounce k2.irq(trigger=Pin.IRQ_FALLING, handler=yellow) k3.irq(trigger=Pin.IRQ_FALLING, handler=red) while 1: # pentru a semnaliza sistem activ led.on() time.sleep(0.5) # temporizare 0,5 secunde led.off() time.sleep(0.5)