This loops through PWM outputs connected to the red and green LED.
Dependencies: mbed
main.cpp
- Committer:
- mattshuman
- Date:
- 2016-06-09
- Revision:
- 0:62faec5d4c84
- Child:
- 1:eceee8965029
File content as of revision 0:62faec5d4c84:
#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. } } }