Microcontroller › 8051 › INTERFACING LCD TO 8051 BY Qurat-ul-ain
- This topic has 23 replies, 12 voices, and was last updated 10 years, 6 months ago by Jaymin D.
-
AuthorPosts
-
November 20, 2011 at 5:56 am #6855Rogen LeeParticipant
hellow Mr. Qaisar. The code that you given is having an error. Is there any solution about this so we can check if it is our circuit or the program is having a problem. Thanks.
November 20, 2011 at 5:58 am #6856Rogen LeeParticipantAaahmmm..about the IC number like the AT89S52, is it really different if I’m going to use other IC number instead of AT89S52?
November 20, 2011 at 6:54 am #6857QaisarParticipanthi lee.
i think u r using s52 . this code will for s52 too .
tha above code is correct as i shown its simulating diagram . i modified delay function .simulate this code now and run it on proteus .
but plz follow the above diagram to run this code .
#include <AT89X51.H>#define lcd_data P2sbit en=P0^1;sbit rs=P0^0;unsigned char z;unsigned int i;void delay(unsigned int time){unsigned int i,j;for(i=0;i<time;i++)for(j=0;j<1275;j++);}void lcdcmd(unsigned char value){lcd_data=value;rs=0;en=1;delay(100);en=0;return;}void lcddata(unsigned char value){lcd_data=value;rs=1;en=1;delay(100);en=0;return;}void main(void){lcdcmd(0X38);//5X7 matrixlcdcmd(0X0E);//lcd on ,curor onlcdcmd(0X01); // clear lcd commandlcdcmd(0X80);//move cursor to line1{unsigned char name[]=” TEST PROGRAMME “;for(z=0;z<=16;z++)lcddata(name[z]);lcdcmd(0XC2); // move cursor to line2, position 2for(i=48;i<=57;i++)lcddata(i);while(1);}}December 19, 2011 at 3:37 pm #6933Syed AameerParticipantif you are using Keil micro vision
then try this code
#include<reg51.h>
#define lcd_data_port P2
sbit rs=P1^0;
sbit rw=P1^1;//better to connect to ground and disable this pin
sbit en=P1^2;
void lcd_cmd(unsigned short temp);
void lcd_data(unsigned short temp);
void delay(unsigned int msec);
void main()
{
lcd_cmd(0x38);
lcd_cmd(0x06);
lcd_cmd(0x0e);
lcd_data(‘A’);
delay(5);
lcd_data(‘B’);
}
void lcd_cmd(unsigned short temp)
{
lcd_data_port=temp;
rs=0;
rw=0;
en=1;
delay(2);
en=0;
}
void lcd_data(unsigned short temp)
{
lcd_data_port=temp;
rs=1;
rw=0;
en=1;
delay(2);
en=0;
}
void delay(unsigned int msec)
{
unsigned int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
March 14, 2012 at 9:25 am #7299werytretrParticipantif im using silicon labs and 8×2 lcd?
March 31, 2012 at 8:15 pm #7371sumankrishnachaparalaParticipantany one have the code and circuit diagram for
lcd based digital alarm clock with digital thermometer using 8051 microcontroller (at89c51)
please send it to [email protected]
thank you in advance
April 13, 2014 at 6:23 am #11544Rohil VermaParticipanti m doing a project using AT89C51 of digital clock, alarm and temp. sensing.. i connected all the components but there are only black boxes on the lcd. i checked it on the proteus software, it was working perfectly. what can i do to get the output?
July 13, 2014 at 12:18 pm #11896HaizadParticipantTry to check the connection to the LCD. Make sure it was soldered properly. Try to adjust the contrast too
July 15, 2014 at 4:14 am #11905Jaymin DParticipantHello,
every one
few new thing about h/w and s/w
just try it it may be useful to all who have LCD problem
1. if u connect LCD with PORT 0 then connect 10K pull-up resistors with M/C
2. connect pin no. 5,1,16 of LCD to GND
3. connect pin n0. 2,15 to +ve 5 V
4. connect excet 10K variable resistor / pot / trimmer as middle pin with pin no. 3 of LCD
below is the sample code for display ” 16×2 character LCD ” on LCD screen
LCD is connect with PORT 2 and RS at pin 1 and EN at pin 2 of PORT 1 and RW is GND in my below code..
just assume this code and you also edit it as per your requriment..
#inclde<REG51.h>
#include<stdio.h>
#defoine lcd P2
sbit rs = P1^0;
sbit en = P1^1;
void cmd(unsigned char value)
{
lcd=value;
rs=0;
en=0;
en=1
}
void data(unsigned char value)
{
lcd=value;
rs=1;
en=0;
en=1
}
void main()
{
unsigned char a[]=”16×2 character LCD”;
unsigned int i;
cmd(0x38);
cmd(0x01);
cmd(0x06);
cmd(0x0E);
cmd(0x80);
for(i=0;a!=’