multipress to change pwm blinky

Dependencies:   mbed

Revision:
0:0dc71bd49f0d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 12 17:31:29 2018 +0000
@@ -0,0 +1,41 @@
+#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);
+    }
+}