7 years, 2 months ago.

LCD not working.

I connected pins 1,5,7,8,9 and 10 to the ground. pins 2 and 3 connected to +Vcc. Pins 11-14 to p16-p19. Pins 4 and 6 to p6 and p7. pins 15 and 16 are just left open. is my connection right? and i've used the TextLCD library by Simon Ford (http://mbed.org/users/simon/code/TextLCD/). This is the Source Code.

  1. include "mbed.h"
  2. include "TextLCD.h"

void slideMessage(char* ,double ,int ); slideMessage(message, slidetime, row )

TextLCD lcd(p24,p26,p27,p28,p29,p30);

  1. define SIZE 16 I don't test TextLCD 20x ... 16x2B

int main() { char msg[] = "1234567890123456" ; char msg1[] = "Welcome to mbed! mbed is a tool for Rapid Prototyping with Microcontrollers." ; slideMessage(msg1, 0.5,0); return 0 ; }

void slideMessage(char msg[], double time,int row) { int j, k ; int len = ( strlen(msg) ) ;

lcd.cls();

while(1){ for (j = SIZE -1 ; j>=0 ; j ) { for ( k = j ; k < SIZE ; k++ ) { lcd.locate(k,row); if ( len > (k - j) ) lcd.printf("%c",msg[k-j]) ; else lcd.printf(" ") ; } wait(time) ; }

for ( j = 1 ; j <= len ; j++ ){ for ( k = 0; k < SIZE ; k++ ){ lcd.locate(k,row) ; if( ( k + j ) < len ) lcd.printf("%c",msg[k+j]) ; else lcd.printf(" ") ; } wait(time) ; } } }

Help me out please. Thankyou.

1 Answer

7 years, 2 months ago.

pin 3 is the LCD contrast voltage. Generally it should be connected to an adjustable positive voltage. Dont connect it to Vcc. Pins 7-10 should generally be left open. The main problem with your code is that you need to use the right pinnames in the declaration of TextLCD. The pins must match your wiring. Your current declaration uses p24 etc. This does not match your wiring. The LCD cookbook page or my enhanced LCD cookbook page provides more information.