multipress example
Dependencies: mbed
main.cpp
- Committer:
- kaushalpkk
- Date:
- 2018-07-12
- Revision:
- 0:5a93e74b5fdf
File content as of revision 0:5a93e74b5fdf:
#include "mbed.h" Timeout flipper; DigitalOut led1(LED1); DigitalOut led2(LED4); InterruptIn button(p14); int count =0; void flip() { if(count == 1) { printf("single press\n"); } else if(count == 2) { printf("double press\n"); } else { printf("multi press\n"); } count = 0; } void press() { printf(">\n"); flipper.attach(&flip, 0.5); count++; } int main(){ printf("Hello world\n"); button.rise(&press); // spin in a main loop. flipper will interrupt it to call flip while(1) { led1 = !led1; wait(4); } }