![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Shows a little more logic and defines off and on for the led's which are false and true respectively. Also, time for blink is a 2-element array.
main.cpp
- Committer:
- scohennm
- Date:
- 2014-09-03
- Revision:
- 1:24090ed5f981
- Parent:
- 0:e23fffd4b9a7
File content as of revision 1:24090ed5f981:
#include "mbed.h" #define LEDON false #define LEDOFF true #define PWMDWELL 50// milliseconds #define DFDELTA 0.01 // slightly more interesting blinky 140814 sc // Change to use PWM float dutyFactor = 0.0; PwmOut greenColor(LED_GREEN); PwmOut redColor(LED_RED); int main() { while(true) { redColor.write(dutyFactor); greenColor.write(1.0 - dutyFactor); dutyFactor += DFDELTA; if(dutyFactor >= 1.0) dutyFactor = 0.0; wait_ms(PWMDWELL); } }