0
\$\begingroup\$

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_Init();                        

  Lcd_Cmd(_LCD_CURSOR_OFF);         
       while(1)
       {
  Lcd_Cmd(_LCD_CLEAR);            
  Lcd_Out(1,6,"Hello ");           
  Lcd_Out(2,6,"World");
  Delay_ms(100);
                  }
  }

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

\$\endgroup\$
18
  • \$\begingroup\$ You forgot to attach the schematic. Also, where do you configure your pins? \$\endgroup\$
    – Armandas
    Commented Mar 14, 2016 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.
    Commented Mar 14, 2016 at 18:43
  • \$\begingroup\$ @Armandas Sorry, it's attached now. \$\endgroup\$
    – Nemo
    Commented Mar 14, 2016 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
    Commented Mar 14, 2016 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.
    Commented Mar 14, 2016 at 20:08

1 Answer 1

1
\$\begingroup\$

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

   while(1){
      Lcd_Cmd(_LCD_CLEAR);            
      Delay_ms( 200 ); // added
      Lcd_Out(1,6,"Hello ");           
      Lcd_Out(2,6,"World");
      Delay_ms( 200 );
 }
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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