Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of blink_kl46z by
main.cpp@3:f445e67012ee, 2015-01-17 (annotated)
- Committer:
- scohennm
- Date:
- Sat Jan 17 23:41:30 2015 +0000
- Revision:
- 3:f445e67012ee
- Parent:
- 2:24090ed5f981
Update revision to include LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scohennm | 0:e23fffd4b9a7 | 1 | #include "mbed.h" |
scohennm | 3:f445e67012ee | 2 | #include "SLCD.h" |
scohennm | 3:f445e67012ee | 3 | |
scohennm | 0:e23fffd4b9a7 | 4 | #define LEDON false |
scohennm | 0:e23fffd4b9a7 | 5 | #define LEDOFF true |
scohennm | 3:f445e67012ee | 6 | #define LCDCHARLEN 10 |
scohennm | 3:f445e67012ee | 7 | #define NUMMESS 2 |
scohennm | 3:f445e67012ee | 8 | #define ONEL " .1" |
scohennm | 3:f445e67012ee | 9 | #define TWOL "2." |
scohennm | 3:f445e67012ee | 10 | |
scohennm | 0:e23fffd4b9a7 | 11 | // slightly more interesting blinky 140814 sc |
scohennm | 3:f445e67012ee | 12 | SLCD slcd; //define LCD display |
scohennm | 3:f445e67012ee | 13 | |
scohennm | 3:f445e67012ee | 14 | float blinks[]={0.400, 0.700}; |
scohennm | 3:f445e67012ee | 15 | int ledState = LEDON; |
scohennm | 3:f445e67012ee | 16 | DigitalOut greenColor(LED_GREEN); |
scohennm | 3:f445e67012ee | 17 | DigitalOut redColor(LED_RED); |
scohennm | 3:f445e67012ee | 18 | int lcdCounter = 1; |
scohennm | 3:f445e67012ee | 19 | |
scohennm | 3:f445e67012ee | 20 | void LCDMess(char *lMess){ |
scohennm | 3:f445e67012ee | 21 | slcd.Home(); |
scohennm | 3:f445e67012ee | 22 | slcd.clear(); |
scohennm | 3:f445e67012ee | 23 | slcd.printf(lMess); |
scohennm | 3:f445e67012ee | 24 | } |
scohennm | 3:f445e67012ee | 25 | //-------------------------------- |
scohennm | 0:e23fffd4b9a7 | 26 | int main() { |
scohennm | 3:f445e67012ee | 27 | char rMess[NUMMESS][LCDCHARLEN]={ONEL, TWOL}; |
scohennm | 3:f445e67012ee | 28 | |
scohennm | 3:f445e67012ee | 29 | |
scohennm | 0:e23fffd4b9a7 | 30 | while(true) { |
scohennm | 3:f445e67012ee | 31 | lcdCounter++; |
scohennm | 3:f445e67012ee | 32 | lcdCounter = lcdCounter % NUMMESS; |
scohennm | 3:f445e67012ee | 33 | ledState = !ledState; // Flip the general state |
scohennm | 3:f445e67012ee | 34 | redColor = ledState; |
scohennm | 3:f445e67012ee | 35 | greenColor = !ledState;// flip state but don't store it. |
scohennm | 3:f445e67012ee | 36 | redColor.write(ledState); |
scohennm | 3:f445e67012ee | 37 | greenColor.write(!ledState);// flip state but don't store it. |
scohennm | 3:f445e67012ee | 38 | LCDMess(rMess[lcdCounter]); |
scohennm | 3:f445e67012ee | 39 | wait(blinks[ledState]); |
scohennm | 0:e23fffd4b9a7 | 40 | } |
scohennm | 3:f445e67012ee | 41 | } |