enter image description hereI wrote the following code to display a blinking text on an lcd. The code works properly on the simulator but the real lcd doesn't display anything. I attached the circuit diagram I used to connect the lcd. I would really appreciate it if someone could tell me what did I do wrong.

[![// LCD module connections
sbit LCD_RS at PORTD.B2;
sbit LCD_EN at PORTD.B3;
sbit LCD_D4 at PORTD.B4;
sbit LCD_D5 at PORTD.B5;
sbit LCD_D6 at PORTD.B6;
sbit LCD_D7 at PORTD.B7;

sbit LCD_RS_Direction at TRISD.B2;
sbit LCD_EN_Direction at TRISD.B3;
sbit LCD_D4_Direction at TRISD.B4;
sbit LCD_D5_Direction at TRISD.B5;
sbit LCD_D6_Direction at TRISD.B6;
sbit LCD_D7_Direction at TRISD.B7;
// End LCD module connections][1]][1]

char MyFirstText[] = "Hello ";

void main(){

  Lcd_Out(1,6,"Hello ");           

P.S: I don't have a 10k potentiometer so I connected a 5k instead.

  • \$\begingroup\$ You forgot to attach the schematic. Also, where do you configure your pins? \$\endgroup\$ – Armandas Mar 14 '16 at 18:41
  • 1
    \$\begingroup\$ I think that you should put the "LCD_CLEAR" command outside of the loop (i.e. before while(1)) or increase the delay to few seconds. \$\endgroup\$ – Roger C. Mar 14 '16 at 18:43
  • \$\begingroup\$ @Armandas Sorry, it's attached now. \$\endgroup\$ – Nemo Mar 14 '16 at 18:49
  • \$\begingroup\$ @RogerC. I have to keep the Lcd_Cmd(_LCD_CLEAR); because I need the text to blink. I could increase the delay though but the things is my lcd doesn't respond at all so I think it might be connection problem. \$\endgroup\$ – Nemo Mar 14 '16 at 18:51
  • 1
    \$\begingroup\$ @Nemo you might use the command LCD_DISPLAYON plus delay followed by LCD_DISPLAYOFF plus delay to produce the blinking effect. \$\endgroup\$ – Roger C. Mar 14 '16 at 20:08

Now that your LCD works: you see no blinking because you have no delay while the display is blank. So it is blank for 0 ms (which you don't notice), then you display the text for 100 ms (which is what you see). Try

      Delay_ms( 200 ); // added
      Lcd_Out(1,6,"Hello ");           
      Delay_ms( 200 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.