This is a test program for TEXT LCD (HD44780) , 40 char x 2 lines.

Dependencies:   TextLCD mbed

Fork of Text_LCD_control by Kenji Arai

Revision:
1:183b7d2bea01
Parent:
0:171b4ca846a6
--- a/main.cpp	Sat Mar 27 07:05:32 2010 +0000
+++ b/main.cpp	Tue Mar 17 23:45:23 2015 +0000
@@ -1,83 +1,87 @@
-//
-//  Text LCD Control Program
-//          Kenji Arai / JH1PJL
-//          March 7th,2010  Started
-//          March 27th,2010  
-//
+//AUTOR: Pedro Santos
+//DATA: 18/12/2014
+//NOTAS: http:
+//CODIGO PARA: programa de teste para entradas e saidas da placa kl25Z
 
 #include "mbed.h"
 #include "TextLCD.h"
 
-#define LINE_40_2
+//#include "Timer_ps.h"
+//********************************************************************
+//********************************************************************
+//DEFINIÇÃO DE ENTRADAS E SAIDAS USADAS NO PROGRAMA
+//SAIDAS DIGITAIS
+DigitalOut  led1        (PTE2);
+DigitalOut  led2        (PTE3);
+DigitalOut  led3        (PTE4);
+DigitalOut  led4        (PTE5);
 
-#define BLINK_PERIOD 1.8        // LED on period (Initial data)
-#define END_PERIOD 0.0001       // Finish period
+DigitalOut  led_r       (LED1); //LED on board 
+DigitalOut  led_g     (LED2); //LED on board 
+DigitalOut  led_b     (LED3); //LED on board 
 
-DigitalOut myled1(LED1);        // Assign LED output port LED1 to LED4
-DigitalOut myled2(LED2);
-DigitalOut myled3(LED3);
-DigitalOut myled4(LED4);
+//********************************************************************
+//ENTRADAS DIGITAIS
+DigitalIn   tecla1      (PTE20);
+DigitalIn   tecla2      (PTE21);
+DigitalIn   tecla3      (PTE22);
+DigitalIn   tecla4      (PTE23);
 
-#ifdef LINE_40_2
-TextLCD lcd(p22, p28, p27, p26, p25, p24, p23, 40, 2); // rs,rw,e,d0,d1,d2,d3,40char's x 2 lines
-#else
-TextLCD lcd(p22, p28, p27, p26, p25, p24, p23, 16, 2); // rs,rw,e,d0,d1,d2,d3,16char's x 2 lines
-#endif
+//********************************************************************
+//********************************************************************
+//Initial condictions:
+void initial_value_ports(){
+    led_r=1;
+    led_g=1;
+    led_b=1;
+    led1=0;
+    led2=0;
+    led3=0;
+    led4=0;
+}
+//********************************************************************
+//********************************************************************
+//Definição de pinos do LCD 16x2:
+TextLCD lcd(PTC6, PTC5, PTC4, PTC3, PTC0, PTC7); // rs,rw,e,d0,d1,d2,d3,16char's x 2 lines
 
 int main() {
-    float tim;
-    long count;
-    char buf[40];
+    
+        initial_value_ports();
+    lcd.cls(); //Clear lcd
+    
+    lcd.locate(0,0);
+    lcd.printf(" Teste LCD 16x2 ");
+    lcd.locate(0,1);
+    lcd.printf("* Pedro Santos *");
+
+    while(1){
 
-    tim = BLINK_PERIOD;
-    count = 0;
-    lcd.cls();
-    lcd.locate(0, 0);
-#ifdef LINE_40_2
-    //          0         1         2         3        40
-    lcd.printf("1234567890123456789012345678901234567890");
-    lcd.locate(0, 1);
-    lcd.printf("0987654321098765432109876543210987654321");
-#else
-    //          0         1     
-    lcd.printf("1234567890123456");
-    lcd.locate(0, 1);
-    lcd.printf("6543210987654321");
-#endif
-    // If you have implemented the "Windows USB Serial Port Driver", you can use follows.
-    // http://mbed.org/projects/handbook/wiki/WindowsSerialConfiguration
-    printf("\r\n  Start LCD Test Program\r\n");
-    while (1) {
-        for (tim =BLINK_PERIOD; tim >=  END_PERIOD; tim /= 3) {
-            myled1 = 1;
-            wait(tim);
-            myled1 = 0;
-            myled2 = 1;
-            wait(tim);
-            myled2 = 0;
-            myled3 = 1;
-            wait(tim);
-            myled3 = 0;
-            myled4 = 1;
-            wait(tim);
-            myled4 = 0;
-        }
-        lcd.cls();
-        lcd.locate(0, 0);   // 1st line top
-#ifdef LINE_40_2
-        //                   1         2         3         4
-        //          1234567890123456789012345678901234567890
-        lcd.printf("This is a test program for checking LCD ");
-        lcd.locate(0, 1);   // 2nd line top
-        sprintf(buf," Current loop count number = %d ", count);
-#else
-        //          1234567890123456
-        lcd.printf("LCD test program");
-        lcd.locate(0, 1);   // 2nd line top
-        sprintf(buf,"loop # = %d", count);
-#endif
-        lcd.printf(buf);
-        printf(" Current loop count number = %d \r\n", count);
-        count++;
+        led_b = 0;
+        wait(0.1); //Wait 100ms
+        led_b = 1;
+        wait(0.1); //Wait 100ms
+        
+        lcd.locate(0,0);
+        lcd.printf(" Teste LCD 16x2 ");
+        lcd.locate(0,1);
+        lcd.printf("* Pedro Santos *");
+        
+        led_g = 0;
+        wait(0.1); //Wait 100ms
+        led_g = 1;
+        wait(0.1); //Wait 100ms
+        
+        wait(1);
+        lcd.locate(0,1);
+        lcd.printf(" Teste LCD 16x2 ");
+        lcd.locate(0,0);
+        lcd.printf("* Pedro Santos *");
+        wait(1);
+        
+
+        led_r = 0;
+        wait(0.1); //Wait 100ms
+        led_r = 1;
+        wait(0.1); //Wait 100ms       
     }
 }