![](/media/cache/profiles/ibmfp2.jpg.50x50_q85.jpg)
Text LCD demo
main.cpp@0:bba654cca6d6, 2011-07-08 (annotated)
- Committer:
- 4180_1
- Date:
- Fri Jul 08 00:42:07 2011 +0000
- Revision:
- 0:bba654cca6d6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:bba654cca6d6 | 1 | #include "mbed.h" |
4180_1 | 0:bba654cca6d6 | 2 | #include "TextLCD.h" |
4180_1 | 0:bba654cca6d6 | 3 | |
4180_1 | 0:bba654cca6d6 | 4 | TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d0-d3 |
4180_1 | 0:bba654cca6d6 | 5 | Timer t; |
4180_1 | 0:bba654cca6d6 | 6 | |
4180_1 | 0:bba654cca6d6 | 7 | int main() { |
4180_1 | 0:bba654cca6d6 | 8 | // Start timer |
4180_1 | 0:bba654cca6d6 | 9 | t.start(); |
4180_1 | 0:bba654cca6d6 | 10 | // Clear LCD Screen |
4180_1 | 0:bba654cca6d6 | 11 | lcd.cls(); |
4180_1 | 0:bba654cca6d6 | 12 | wait(1); |
4180_1 | 0:bba654cca6d6 | 13 | // Print to LCD on first line |
4180_1 | 0:bba654cca6d6 | 14 | lcd.printf("Hello LCD World!\n"); |
4180_1 | 0:bba654cca6d6 | 15 | while (1) { |
4180_1 | 0:bba654cca6d6 | 16 | // Move cursor to start of second display line |
4180_1 | 0:bba654cca6d6 | 17 | lcd.locate(0,1); |
4180_1 | 0:bba654cca6d6 | 18 | // Print elapsed time from timer on LCD |
4180_1 | 0:bba654cca6d6 | 19 | lcd.printf("%e sec", t.read()); |
4180_1 | 0:bba654cca6d6 | 20 | wait(.2); |
4180_1 | 0:bba654cca6d6 | 21 | } |
4180_1 | 0:bba654cca6d6 | 22 | } |