multipress to change pwm blinky
Dependencies: mbed
main.cpp
- Committer:
- kaushalpkk
- Date:
- 2018-07-12
- Revision:
- 0:0dc71bd49f0d
File content as of revision 0:0dc71bd49f0d:
#include "mbed.h" Timeout flipper; DigitalOut led1(LED1); PwmOut led2(LED4); InterruptIn button(p14); int count =0; void flip() { if(count == 1) { printf("single press\n"); led2 = 0; } else if(count == 2) { printf("double press\n"); led2 = 0.3; } else { printf("multi press\n"); led2 = 1; } 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); } }