Dash Button - use interrupt for buttons



  • Any idea how to make use of the interrupts for the buttons? I want to exec an interrupt whenever one of the buttons is pressed. this way I avoid the button check on each loop. I used the std Arduino call, butt this didn't work :(

    void button_handler() {
    // code to exec when button pressed
    }
    
    attachInterrupt(23, button_handler, RISING);
    


  • you can refer the InterruptCtrlLed example.
    0_1514859456929_upload-6564de7b-c948-4a7b-9520-291691beb725



  • I tried this - this didn't work :( The Dash Button Keys are connected to pins
    23, 14, 10, 20. Do those support interrupts? I tried the InterruptCtrlLed example and replaced int button = 12; for int button = 23;. I wrapped this into OTA example for easier upload - could this be a problem?



  • pin10 does not support interrupt, pin 23, 14, 20 support interrupt.
    use INPUT_IRQ_FALL instead of INPUT_IRQ_RISE

    0_1515054530715_upload-d73b928a-a6a1-4a10-9b62-0d8aed173533



  • Thanks, changing to INPUT_IRQ_FALL worked. To bad pin 10 doesn't have an IRQ attached :(

    weird thing I figured: with pin14 I get an irq when pressing AND releasing. for pin 23 and pin 20, just when pressing. why that?



  • I try it and same situation with you, the pin14 may not be stable for gpio irq use.



  • ah ok :( I see IRQ called once when pressing, but when I release button it's very bouncy - the IRC gets called up to 30 times, event value is either 2 or 1. I'll have to stabilize via software then...


Log in to reply
 

Looks like your connection to RAK Support Center was lost, please wait while we try to reconnect.