lab 7

Dependencies:   mbed

Fork of LAB07_Oppgave4_Template by EN-SOC3001

Files at this revision

API Documentation at this revision

Comitter:
eivindd24
Date:
Sat Dec 10 10:22:50 2016 +0000
Parent:
0:ce0d1043321f
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
--- a/main.cpp	Wed Oct 14 19:06:20 2015 +0000
+++ b/main.cpp	Sat Dec 10 10:22:50 2016 +0000
@@ -3,6 +3,8 @@
 Timeout    onTime;
 Ticker     periodTimer;
 DigitalOut led(PA_9); 
+InterruptIn SW7(PB_3);
+InterruptIn SW6(PA_10);
 
 float periodTime=0.020;  // 20ms period time (50Hz)
 float dutyCycle=.05;
@@ -11,6 +13,20 @@
 {   led=1;
 }
 
+void SW7Trykk(){
+    dutyCycle=dutyCycle+.1f;
+}
+
+void SW6Trykk(){
+    
+    dutyCycle=dutyCycle-.1f;
+    if(dutyCycle<=0.1)
+    {
+        dutyCycle=0.1;    
+    }
+    
+}
+
 void TurnLightOn()
 {   led=0;
     onTime.attach(&TurnLightOff,(float)periodTime*dutyCycle);
@@ -21,6 +37,8 @@
     periodTimer.attach(&TurnLightOn,periodTime);
 
     while(1) {
+        SW7.fall(&SW7Trykk);
+        SW6.fall(&SW6Trykk);
         wait(1);
     }
 }
--- a/mbed.bld	Wed Oct 14 19:06:20 2015 +0000
+++ b/mbed.bld	Sat Dec 10 10:22:50 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file