oppg3

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
eivindd24
Date:
Sat Dec 10 10:25:56 2016 +0000
Commit message:
ok;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Dec 10 10:25:56 2016 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+
+Ticker toggle_led_ticker;
+InterruptIn SW7(PB_3);
+InterruptIn SW6(PA_10);
+float tikerhastighet=0.1;
+DigitalOut led1(PA_9);
+Timeout    timeOutIrq;
+
+void toggle_led() 
+{
+    led1 = !led1;
+}
+
+void enableKnappeTrykk(){
+    SW7.enable_irq();
+    SW6.enable_irq();
+}
+
+
+void sw7Trykket()
+{
+    SW7.disable_irq();
+    timeOutIrq.attach(&enableKnappeTrykk,.5);
+    tikerhastighet=tikerhastighet-.01f;
+    toggle_led_ticker.attach(&toggle_led, tikerhastighet);
+}
+
+void sw6Trykket()
+{
+    SW6.disable_irq();
+    timeOutIrq.attach(&enableKnappeTrykk,.5);
+    tikerhastighet=tikerhastighet+.01f;
+    toggle_led_ticker.attach(&toggle_led, tikerhastighet);
+
+}
+
+int main() {
+    // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms)
+    toggle_led_ticker.attach(&toggle_led, 0.1);
+    while (true) 
+    {    
+        SW6.fall(&sw6Trykket);
+        SW7.fall(&sw7Trykket);
+        
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Dec 10 10:25:56 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file