s
Dependencies: mbed
Fork of LAB07_Oppgave4_Template by
Diff: main.cpp
- Revision:
- 1:3313c84ab6d7
- Parent:
- 0:ce0d1043321f
--- a/main.cpp Wed Oct 14 19:06:20 2015 +0000 +++ b/main.cpp Thu Oct 15 15:01:49 2015 +0000 @@ -1,8 +1,10 @@ #include "mbed.h" +Ticker led_ticker; Timeout onTime; Ticker periodTimer; DigitalOut led(PA_9); +InterruptIn SW6(PA_10), SW7(PB_3); float periodTime=0.020; // 20ms period time (50Hz) float dutyCycle=.05; @@ -16,9 +18,21 @@ onTime.attach(&TurnLightOff,(float)periodTime*dutyCycle); } +void SW7Trykket() +{ dutyCycle=dutyCycle+.1f; + //led_ticker.attach(&led, dutyCycle); +} + void SW6Trykket() +{ dutyCycle=dutyCycle-.1f; + //led_ticker.attach(&led, dutyCycle); +} + int main() { + if (dutyCycle>0); periodTimer.attach(&TurnLightOn,periodTime); + SW7.fall(&SW7Trykket); + SW6.fall(&SW6Trykket); while(1) { wait(1);