Lab08 Oppgave 1 template
Dependencies: mbed
Import program
00001 #include "mbed.h" 00002 00003 PwmOut pwmLed(PB_9); 00004 00005 int main() 00006 { 00007 pwmLed.period(0.020); // 20ms Periode tid 00008 00009 //Set the led ouput duty-cycle to 1% 00010 float brightness=0.01; 00011 pwmLed=brightness; 00012 00013 printf("Press 'u' to turn LED1 brightness up, 'd' for down\n\r"); 00014 while(1) { 00015 00016 char c = getchar(); 00017 if((c == 'u') && (brightness < 0.1f)) 00018 brightness += 0.001f; 00019 if((c == 'd') && (brightness > 0.0f)) 00020 brightness -= 0.001f; 00021 00022 //Set the ouput duty-cycle, specified as a percentage 00023 pwmLed = brightness; 00024 printf("%c %1.3f \n \r",c,brightness); 00025 } 00026 } 00027