Frank Vannieuwkerke
/
mbed-shiny
An alternative to mbed-blinky using PDM dimming.
Diff: main.cpp
- Revision:
- 0:26a3db3ba847
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 25 11:20:17 2014 +0000 @@ -0,0 +1,23 @@ +// 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; + } +} \ No newline at end of file