An alternative to mbed-blinky using PDM dimming.

Dependencies:   SoftPdmOut mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // mbed-shiny
00002 #include "mbed.h"
00003 #include "SoftPdmOut.h"
00004  
00005 SoftPdmOut pdm(LED1);
00006  
00007 int main()
00008 {
00009     float pdmSet = 0.0f;
00010     float pdmAdd = 0.01f;
00011  
00012     // Continuously cycle the output
00013     while(1)
00014     {
00015         pdm = pdmSet;
00016         wait_ms(10);
00017         if(pdmSet >= 1.0f)
00018             pdmAdd = -0.01f;
00019         if(pdmSet <= 0.0f)
00020             pdmAdd = 0.01f;
00021         pdmSet += pdmAdd;
00022     }
00023 }