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.
Dependents: SoftPWM_Example XYZ_Joystick_PWM mbed_pwm mbed_Ahan_robocon ... more
You are viewing an older revision! See the latest version
Homepage
<<code title=include the mbed library with this snippet>>
- include "mbed.h"
- include "math.h"
- include "SoftPWM.h" Blink the LED smoothly with PWM. Also, this project is test of the math function.
/**
- \brief LED to control
- / SoftPWM myled1(LED1); SoftPWM myled2(LED2); SoftPWM myled3(LED3); SoftPWM myled4(LED4);
/**
- \brief main program
- / int main() { myled1.period_ms( 1 ); myled2.period_ms( 1 ); myled3.period_ms( 1 ); myled4.period_ms( 1 ); while (1) for ( int i=0; i<360; i+=10 ) { myled1 = cos( i*2.0*3.14/360 ) * 0.5 + 0.5; wait(0.01); myled2 = cos( (i+90)*2.0*3.14/360 ) * 0.5 + 0.5; wait(0.01); myled3 = cos( (i+180)*2.0*3.14/360 ) * 0.5 + 0.5; wait(0.01); myled4 = cos( (i+270)*2.0*3.14/360 ) * 0.5 + 0.5; wait(0.01); } }<</code>>