![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Use long-hand write on Digital I/O
Fork of blink_kl46z by
Diff: main.cpp
- Revision:
- 3:f445e67012ee
- Parent:
- 2:24090ed5f981
--- a/main.cpp Wed Sep 03 15:03:30 2014 +0000 +++ b/main.cpp Sat Jan 17 23:41:30 2015 +0000 @@ -1,22 +1,41 @@ #include "mbed.h" +#include "SLCD.h" + #define LEDON false #define LEDOFF true -#define PWMDWELL 50// milliseconds -#define DFDELTA 0.01 - +#define LCDCHARLEN 10 +#define NUMMESS 2 +#define ONEL " .1" +#define TWOL "2." + // slightly more interesting blinky 140814 sc -// Change to use PWM - -float dutyFactor = 0.0; -PwmOut greenColor(LED_GREEN); -PwmOut redColor(LED_RED); - +SLCD slcd; //define LCD display + +float blinks[]={0.400, 0.700}; +int ledState = LEDON; +DigitalOut greenColor(LED_GREEN); +DigitalOut redColor(LED_RED); +int lcdCounter = 1; + +void LCDMess(char *lMess){ + slcd.Home(); + slcd.clear(); + slcd.printf(lMess); +} +//-------------------------------- int main() { + char rMess[NUMMESS][LCDCHARLEN]={ONEL, TWOL}; + + while(true) { - redColor.write(dutyFactor); - greenColor.write(1.0 - dutyFactor); - dutyFactor += DFDELTA; - if(dutyFactor >= 1.0) dutyFactor = 0.0; - wait_ms(PWMDWELL); + lcdCounter++; + lcdCounter = lcdCounter % NUMMESS; + ledState = !ledState; // Flip the general state + redColor = ledState; + greenColor = !ledState;// flip state but don't store it. + redColor.write(ledState); + greenColor.write(!ledState);// flip state but don't store it. + LCDMess(rMess[lcdCounter]); + wait(blinks[ledState]); } -} \ No newline at end of file +}