Do you see the backlight and blinking cursor on LCD...? If you do so, then there would be problem with LCD_write section of the above code...It's just blank
Here is the datasheet for your model JHD162A which uses the KS0066 Controller Chipset:
**broken link removed**
Keep a copy of the datasheet handy for future reference.
Have you installed the resistors?
BigDog
#include<htc.h>
#include"lcd.h"
void delayus(unsigned char delay){
while(delay--);
}
void delayms(unsigned char delay){
while(delay--)
delayus(149);
}
void lcd_reset()
{
LCD = 0xFF;
delayms(40);
LCD = 0x03+LCD_EN;
LCD = 0x03;
delayms(40);
LCD = 0x03+LCD_EN;
LCD = 0x03;
delayms(5);
LCD = 0x03+LCD_EN;
LCD = 0x03;
delayms(5);
LCD = 0x02+LCD_EN;
LCD = 0x02;
delayms(5);
}
void lcd_init ()
{
TRISC = 0x20;
//CMCON |= 111; //make RA3:RA0 as digital and disable comparator
lcd_reset();
lcd_cmd(LCD_SETFUNCTION); // 4-bit mode - 1 line - 5x7 font.
lcd_cmd(LCD_SETVISIBLE+0x04); // Display no cursor - no blink.
lcd_cmd(LCD_SETMODE+0x02); // Automatic Increment - No Display shift.
lcd_cmd(LCD_SETDDADDR); // Address DDRAM with 0 offset 80h.
}
void lcd_cmd (char cmd)
{
LCD = ((cmd >> 4) & 0x0F)|LCD_EN;
LCD = ((cmd >> 4) & 0x0F);
LCD = (cmd & 0x0F)|LCD_EN;
LCD = (cmd & 0x0F);
delayus(250);
delayus(250);
}
void lcd_data (unsigned char dat)
{
LCD = (((dat >> 4) & 0x0F)|LCD_EN|LCD_RS);
LCD = (((dat >> 4) & 0x0F)|LCD_RS);
LCD = ((dat & 0x0F)|LCD_EN|LCD_RS);
LCD = ((dat & 0x0F)|LCD_RS);
delayus(250);
delayus(250);
}
void lcd_str (unsigned char *str)
{
while(*str)
lcd_data(*str++);
}
How to check if my lcd 16 x 2 is working or not?
I didn't try with a potentiometer. I connected a 10 k resistor to the point 3 and grounded it's(10k) other end. I still got the same output.
No one answered me this question.
How to check if my lcd 16 x 2 is working or not?
From the photo, I guess your problem is improper initialization. If the hardware connections are okay and if you powered the LCD, it will show like this as in your photo. Nothing is wrong with the LCD. After a proper initialization only it will enter the working mode.
I think this is the best link for LCD:
Initialization Issues
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?