Thanks for the reply @hippy
Yeah, I did figure out the import machine problem later after I posted last time and changed the irq to add 'machine.Pin'. Though it still hangs at button press without any error posted to shell. I'll post what I came up with from your example. Although, I think the hang may be coming from the fact that the irq is not operating on the second processing core.
Yeah, I did figure out the import machine problem later after I posted last time and changed the irq to add 'machine.Pin'. Though it still hangs at button press without any error posted to shell. I'll post what I came up with from your example. Although, I think the hang may be coming from the fact that the irq is not operating on the second processing core.
Code:
import machineimport utimeled_red = machine.Pin(15, machine.Pin.OUT)led_amber = machine.Pin(14, machine.Pin.OUT)led_green = machine.Pin(13, machine.Pin.OUT)button = machine.Pin(16, machine.Pin.IN, machine.Pin.PULL_DOWN)buzzer = machine.Pin(12, machine.Pin.OUT)global button_pressedbutton_pressed = Falsedef ButtonPushedHandler(self): global button_pressed while True: utime.sleep(0.1) if button.value() == 1: button_pressed = True button.irq(trigger=macine.Pin.IRQ_RISING, handler=ButtonPushedHandler)while True: if button_pressed == True: led_red.value(1) for i in range(10): buzzer.value(1) utime.sleep(0.2) buzzer.value(0) utime.sleep(0.2) global button_pressed button_pressed = False led_red.value(1) utime.sleep(5) led_amber.value(1) utime.sleep(2) led_red.value(0) led_amber.value(0) led_green.value(1) utime.sleep(5) led_green.value(0) led_amber.value(1) utime.sleep(5) led_amber.value(0)
Statistics: Posted by Rueful-Pi — Tue May 07, 2024 9:04 pm