ravi butani
/
MEFGI
Advanced Micro Processor Experiments SEM-6 Marwadi Education Foundation Rajkot
main.cpp@0:c7aaecd69812, 2016-04-12 (annotated)
- Committer:
- rx5
- Date:
- Tue Apr 12 06:08:15 2016 +0000
- Revision:
- 0:c7aaecd69812
MEFGI, RAJKOT EC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rx5 | 0:c7aaecd69812 | 1 | #include "mbed.h" |
rx5 | 0:c7aaecd69812 | 2 | #include "TextLCD.h" |
rx5 | 0:c7aaecd69812 | 3 | TextLCD lcd(D2, D3, D4, D5, D6, D7); // LCD PIN => RS, EN, Data4, Data5, Data6, Data7 |
rx5 | 0:c7aaecd69812 | 4 | |
rx5 | 0:c7aaecd69812 | 5 | int main() |
rx5 | 0:c7aaecd69812 | 6 | { |
rx5 | 0:c7aaecd69812 | 7 | int i=0; |
rx5 | 0:c7aaecd69812 | 8 | float f=0; |
rx5 | 0:c7aaecd69812 | 9 | lcd.cls(); // Clear LCD |
rx5 | 0:c7aaecd69812 | 10 | lcd.locate(0,0); // cursor on Col=0, Raw=0 |
rx5 | 0:c7aaecd69812 | 11 | lcd.printf("Experiment - 4"); // print startup message on LCD first Raw |
rx5 | 0:c7aaecd69812 | 12 | lcd.locate(0,1); // cursor on Col=0, Raw=1 |
rx5 | 0:c7aaecd69812 | 13 | lcd.printf("LCD Interfacing"); // print startup message on LCD second Raw |
rx5 | 0:c7aaecd69812 | 14 | wait(3.0); // wait 3 second to show startup message |
rx5 | 0:c7aaecd69812 | 15 | while(1) // loop forever |
rx5 | 0:c7aaecd69812 | 16 | { |
rx5 | 0:c7aaecd69812 | 17 | lcd.cls(); // Clear LCD |
rx5 | 0:c7aaecd69812 | 18 | lcd.locate(0,0); // cursor on Col=0, Raw=0 |
rx5 | 0:c7aaecd69812 | 19 | lcd.printf("Int i = %d",i); // print value of i in first line of LCD |
rx5 | 0:c7aaecd69812 | 20 | lcd.locate(0,1); // cursor on Col=0, Raw=1 |
rx5 | 0:c7aaecd69812 | 21 | lcd.printf("Float f = %0.2f",f); // print value of f with resolution of two decimal point in second line of LCD |
rx5 | 0:c7aaecd69812 | 22 | i=i+1; // update i |
rx5 | 0:c7aaecd69812 | 23 | f=f+0.01; // update f |
rx5 | 0:c7aaecd69812 | 24 | wait(1.0); // Wait for 1 second |
rx5 | 0:c7aaecd69812 | 25 | |
rx5 | 0:c7aaecd69812 | 26 | } |
rx5 | 0:c7aaecd69812 | 27 | |
rx5 | 0:c7aaecd69812 | 28 | } |