Eivind Dammen
/
LAB07_Oppgave4
lab 7
Fork of LAB07_Oppgave4_Template by
Diff: main.cpp
- Revision:
- 1:97d80c580b14
- Parent:
- 0:ce0d1043321f
--- 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); } }