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

#include "mbed.h"
#include "math.h"
#include "SoftPWM.h"

SoftPWM led[] = { LED1,LED2,LED3,LED4 };

int main()
{
    for ( int i=0; i<4; i++ ) led[i].period_ms( 1 );
    while (1)   {
        for ( int j=0; j<360; j+=10 ) {
            for ( int k=0; k<4; k++ ) {
                led[k] = cos( (j+k*90)*2.0*3.14/360 ) * 0.5 + 0.5;
                wait(0.01);
            }
        }
    }
}
Download repository: zip gz

Files at revision 0:7918ce37626c

Name Size Actions
[up]
SoftPWM.cpp 1734 Revisions Annotate
SoftPWM.h 1001 Revisions Annotate