s
Dependencies: mbed
Fork of LAB07_Oppgave4_Template by
main.cpp
- Committer:
- Voldread
- Date:
- 2015-10-15
- Revision:
- 1:3313c84ab6d7
- Parent:
- 0:ce0d1043321f
File content as of revision 1:3313c84ab6d7:
#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; void TurnLightOff() { led=1; } void TurnLightOn() { led=0; 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); } }