This loops through PWM outputs connected to the red and green LED.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:62faec5d4c84
- Child:
- 1:eceee8965029
diff -r 000000000000 -r 62faec5d4c84 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 09 18:29:57 2016 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" + +PwmOut r(LED_RED); +PwmOut g(LED_GREEN); + +int main() +{ + r.period(0.001f); + g.period(0.001f); + + while (true) { + for (float i = 0.0f; i < 1.0f ; i += 0.001f) { + float p = 2 * i; //Sweep the p value between 0 and 2, with .002 steps + r = p%1; //Sweep the red LED 2 times during the loop, igorning the integer portion of the float number. + g = i; //Sweep the green LED 1 time during the loop. + wait (0.0025f); //Wait 2.5 milliseconds per iteration, 2.5 seconds per full loop. + } + } +}