Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Homepage
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