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.
main.cpp
00001 #include "mbed.h" 00002 00003 PwmOut mypwm(LED1); 00004 00005 00006 00007 int main() { 00008 00009 00010 00011 printf("pwm set to %.2f %%\n", mypwm.read() * 100); 00012 00013 float pwm=0.0; 00014 00015 while(1) { 00016 00017 pwm = pwm + 0.05; // instead of this pattern we can also write like check below 00018 mypwm.write(pwm); 00019 if(pwm >= 1.0) 00020 pwm = 0.0; 00021 wait(0.03); 00022 00023 /* 00024 mypwm = mypwm + 0.01; 00025 if(mypwm >= 1.0) 00026 mypwm = 0.0; 00027 wait(0.05); 00028 //and here we will not need any "float pwm=0.0;" type vars 00029 //another thing is that even if we don't set the pwm.period default period will be used which will be 00030 //same across the whole program for any number of pwms used on that chip. 00031 */ 00032 00033 } 00034 }
Generated on Tue Oct 11 2022 06:41:08 by
1.7.2