LED output example l by Soft PWM.
Fork of pwmLED by
Diff: main.cpp
- Revision:
- 0:b3a395ee08f3
- Child:
- 1:155dd5b24708
diff -r 000000000000 -r b3a395ee08f3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Oct 17 05:53:09 2010 +0000 @@ -0,0 +1,28 @@ +/** +* \file main.cpp +* \brief main program +*/ + +#include "mbed.h" +#include "math.h" + +// Blink the LED smoothly with PWM. +// Also, this project is test of the math function. + +/** +* \brief LED to control +*/ +PwmOut myled(LED1); + + +/** +* \brief main program +*/ +int main() { + myled.period_ms( 1 ); + while (1) + for ( int i=0; i<360; i+=10 ) { + myled = cos( i*2.0*3.14/360 ) * 0.5 + 0.5; + wait(0.03); + } +}