Multi function button

22 Feb 2019

Hello, I'm new with mbed and c++ programing. I have played simple ready made codes (buttons, leds,lcd ..) with my stm32 (nucleof411) board. Now i'm trying to do multi function button with calculating button pressed time.

Something like this: button pressed 1 to 999ms -> turn only led1 on button pressed 1000 to 3000ms -> turn only led2 on button pressed over 3000ms -> turn only led3 on

i dont'n know where to start :)

24 Sep 2019

Hi Jukka,

Add interrupt to the button. Add fall and rise functions. https://os.mbed.com/docs/mbed-os/v5.13/apis/interruptin.html#interruptin-hello-world Then add start timer to fall function and stop timer to rise function. https://os.mbed.com/docs/mbed-os/v5.13/apis/timer.html#timer-hello-world Then on the rise function look the timer measure time and turn the wanted led on.

Regards, Pekka