The PWM output by software. Can be output to any pin. It can be used to replace the Pwmout.
Dependents: SoftPWM_Example XYZ_Joystick_PWM mbed_pwm mbed_Ahan_robocon ... more
You are viewing an older revision! See the latest version
Homepage
/** * \file main.cpp * \brief main program */ #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); } }