Daniel Bromand
/
Counter_with_LCD_Display
Counter with LCD Display
main.cpp@1:f580beec166a, 2011-06-28 (annotated)
- Committer:
- bromand
- Date:
- Tue Jun 28 18:46:51 2011 +0000
- Revision:
- 1:f580beec166a
- Parent:
- 0:1abd7e24ae31
1.0.0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bromand | 0:1abd7e24ae31 | 1 | //Include mbed header file which contains the definition of DigitalOut class. |
bromand | 0:1abd7e24ae31 | 2 | #include "mbed.h" |
bromand | 0:1abd7e24ae31 | 3 | //Include TextLCD header file which contains the definition of TextLCD class. |
bromand | 0:1abd7e24ae31 | 4 | #include "TextLCD.h" |
bromand | 0:1abd7e24ae31 | 5 | |
bromand | 0:1abd7e24ae31 | 6 | //Initialize TextLCD with the correct pins |
bromand | 0:1abd7e24ae31 | 7 | TextLCD lcd(p24, p26, p27, p28, p29, p30); |
bromand | 0:1abd7e24ae31 | 8 | |
bromand | 0:1abd7e24ae31 | 9 | //Main function |
bromand | 0:1abd7e24ae31 | 10 | int main() |
bromand | 0:1abd7e24ae31 | 11 | { |
bromand | 0:1abd7e24ae31 | 12 | //Clear the LCD display |
bromand | 0:1abd7e24ae31 | 13 | lcd.cls(); |
bromand | 0:1abd7e24ae31 | 14 | //Locate Row 0 Column 0 in the LCD display |
bromand | 0:1abd7e24ae31 | 15 | lcd.locate(0, 0); |
bromand | 0:1abd7e24ae31 | 16 | //Print "The End" |
bromand | 0:1abd7e24ae31 | 17 | lcd.printf("Start Counting:"); |
bromand | 0:1abd7e24ae31 | 18 | //Iterate between 0 and 1000. |
bromand | 0:1abd7e24ae31 | 19 | for(int i=0 ; i<=1000 ; i++) |
bromand | 0:1abd7e24ae31 | 20 | { |
bromand | 1:f580beec166a | 21 | //Locate Row 1 Column 0 in the LCD display |
bromand | 1:f580beec166a | 22 | lcd.locate(0, 1); |
bromand | 0:1abd7e24ae31 | 23 | //Call PrintToLCD function |
bromand | 1:f580beec166a | 24 | lcd.printf("%d", i); |
bromand | 0:1abd7e24ae31 | 25 | //wait for 250ms |
bromand | 0:1abd7e24ae31 | 26 | wait(0.25); |
bromand | 0:1abd7e24ae31 | 27 | } |
bromand | 0:1abd7e24ae31 | 28 | //Clear the LCD display |
bromand | 0:1abd7e24ae31 | 29 | lcd.cls(); |
bromand | 0:1abd7e24ae31 | 30 | //Locate Row 0 Column 0 in the LCD display |
bromand | 0:1abd7e24ae31 | 31 | lcd.locate(0, 0); |
bromand | 0:1abd7e24ae31 | 32 | //Print "The End" |
bromand | 0:1abd7e24ae31 | 33 | lcd.printf("The End!!!"); |
bromand | 0:1abd7e24ae31 | 34 | } |