An alternative to mbed-blinky using PDM dimming.

Dependencies:   SoftPdmOut mbed

main.cpp

Committer:
frankvnk
Date:
2014-12-28
Revision:
5:bfed8914e2ca
Parent:
0:26a3db3ba847

File content as of revision 5:bfed8914e2ca:

// mbed-shiny
#include "mbed.h"
#include "SoftPdmOut.h"
 
SoftPdmOut pdm(LED1);
 
int main()
{
    float pdmSet = 0.0f;
    float pdmAdd = 0.01f;
 
    // Continuously cycle the output
    while(1)
    {
        pdm = pdmSet;
        wait_ms(10);
        if(pdmSet >= 1.0f)
            pdmAdd = -0.01f;
        if(pdmSet <= 0.0f)
            pdmAdd = 0.01f;
        pdmSet += pdmAdd;
    }
}