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.
main.cpp
00001 // 00002 // Text LCD Control Program 00003 // Kenji Arai / JH1PJL 00004 // March 7th,2010 Started 00005 // March 27th,2010 00006 // 00007 00008 #include "mbed.h" 00009 #include "TextLCD.h" 00010 00011 #define LINE_40_2 00012 00013 #define BLINK_PERIOD 1.8 // LED on period (Initial data) 00014 #define END_PERIOD 0.0001 // Finish period 00015 00016 DigitalOut myled1(LED1); // Assign LED output port LED1 to LED4 00017 DigitalOut myled2(LED2); 00018 DigitalOut myled3(LED3); 00019 DigitalOut myled4(LED4); 00020 00021 #ifdef LINE_40_2 00022 TextLCD lcd(p22, p28, p27, p26, p25, p24, p23, 40, 2); // rs,rw,e,d0,d1,d2,d3,40char's x 2 lines 00023 #else 00024 TextLCD lcd(p22, p28, p27, p26, p25, p24, p23, 16, 2); // rs,rw,e,d0,d1,d2,d3,16char's x 2 lines 00025 #endif 00026 00027 int main() { 00028 float tim; 00029 long count; 00030 char buf[40]; 00031 00032 tim = BLINK_PERIOD; 00033 count = 0; 00034 lcd.cls(); 00035 lcd.locate(0, 0); 00036 #ifdef LINE_40_2 00037 // 0 1 2 3 40 00038 lcd.printf("1234567890123456789012345678901234567890"); 00039 lcd.locate(0, 1); 00040 lcd.printf("0987654321098765432109876543210987654321"); 00041 #else 00042 // 0 1 00043 lcd.printf("1234567890123456"); 00044 lcd.locate(0, 1); 00045 lcd.printf("6543210987654321"); 00046 #endif 00047 // If you have implemented the "Windows USB Serial Port Driver", you can use follows. 00048 // http://mbed.org/projects/handbook/wiki/WindowsSerialConfiguration 00049 printf("\r\n Start LCD Test Program\r\n"); 00050 while (1) { 00051 for (tim =BLINK_PERIOD; tim >= END_PERIOD; tim /= 3) { 00052 myled1 = 1; 00053 wait(tim); 00054 myled1 = 0; 00055 myled2 = 1; 00056 wait(tim); 00057 myled2 = 0; 00058 myled3 = 1; 00059 wait(tim); 00060 myled3 = 0; 00061 myled4 = 1; 00062 wait(tim); 00063 myled4 = 0; 00064 } 00065 lcd.cls(); 00066 lcd.locate(0, 0); // 1st line top 00067 #ifdef LINE_40_2 00068 // 1 2 3 4 00069 // 1234567890123456789012345678901234567890 00070 lcd.printf("This is a test program for checking LCD "); 00071 lcd.locate(0, 1); // 2nd line top 00072 sprintf(buf," Current loop count number = %d ", count); 00073 #else 00074 // 1234567890123456 00075 lcd.printf("LCD test program"); 00076 lcd.locate(0, 1); // 2nd line top 00077 sprintf(buf,"loop # = %d", count); 00078 #endif 00079 lcd.printf(buf); 00080 printf(" Current loop count number = %d \r\n", count); 00081 count++; 00082 } 00083 }
Generated on Thu Jul 14 2022 18:21:08 by
1.7.2