Vjezba 6_4

Dependencies:   mbed

Revision:
8:e81d54d7ced6
Parent:
7:c56b212b084e
--- a/main.cpp	Thu Nov 10 18:02:06 2016 +0000
+++ b/main.cpp	Thu Nov 10 18:18:17 2016 +0000
@@ -1,28 +1,12 @@
 #include "mbed.h"
-Ticker flipper1;
-Ticker flipper2;
-DigitalOut led1(p5);
-DigitalOut led2(p6);
-void flip1()   // flip 1 function
-{
-    led1 = !led1;
-}
-void flip2()   // flip 2 function
-{
-    led2 = !led2;
-}
+InterruptIn button(p18); // Interrupt on digital pushbutton input p18
+DigitalOut led1(p5); // digital out to p5
+void toggle(void); // function prototype
 int main()
 {
-    led1 = 0;
-    led2 = 0;
-    flipper1.attach(&flip1, 0.2); // the address of the
-// function to be attached
-// and the interval (sec)
-    flipper2.attach(&flip2, 1.0);
-// spin in a main loop
-// flipper will interrupt it to call flip
-    while(1) {
-        wait(0.2);
-    }
+    button.rise(&toggle); // attach the address of the toggle
+} // function to the rising edge
+void toggle()
+{
+    led1=!led1;
 }
-}
\ No newline at end of file