Copy and work the circuit in proteus, write the code in keil software
Program 1:
#include<reg51.h>
sfr LCD = 0x90; // Port 1 SFR
sbit RS = P3^5;
sbit EN = P3^4;
sbit RW = P3^6;
void Delay(unsigned int itime);
void main()
{
P1=0x38;
RS=0;
RW=0;
EN=1;
Delay(5);
EN=0;
P1=0x01;
RS=0;
RW=0;
EN=1;
Delay(5);
EN=0;
P1=0x06;
RS=0;
RW=0;
EN=1;
Delay(5);
EN=0;
P1=0x0E;
RS=0;
RW=0;
EN=1;
Delay(5);
EN=0;
P1=0x80;
RS=0;
RW=0;
EN=1;
Delay(5);
EN=0;
P1='H';
RS=1;
RW=0;
EN=1;
Delay(5);
EN=0;
P1='E';
RS=1;
RW=0;
EN=1;
Delay(5);
EN=0;
P1='L';
RS=1;
RW=0;
EN=1;
Delay(5);
EN=0;
P1='L';
RS=1;
RW=0;
EN=1;
Delay(5);
EN=0;
P1='O';
RS=1;
RW=0;
EN=1;
Delay(5);
EN=0;
}
void Delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<1275;i++)
for(j=0;j<itime;j++);
}
Program 2
#include<reg51.h>
#include<string.h>
sfr LCD = 0x90;
sbit RS = P3^5;
sbit EN = P3^4;
sbit RW = P3^6;
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void lcdstr(unsigned char msg[]);
void Delay(unsigned int itime);
void main()
{
lcdcmd(0x38);
Delay(1);
lcdcmd(0x01);
Delay(1);
lcdcmd(0x06);
Delay(1);
lcdcmd(0x0C);
Delay(1);
lcdcmd(0x80);
Delay(1);
lcdstr("Hello World");
while(1);
}
void lcdcmd(unsigned char value)
{
LCD = value;
RS = 0;
RW = 0;
EN = 1;
Delay(1);
EN = 0;
}
void lcddata(unsigned char value)
{
LCD = value;
RS = 1;
RW = 0;
EN = 1;
Delay(1);
EN = 0;
}
void Delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<1275;i++)
for(j=0;j<itime;j++);
}
void lcdstr(unsigned char msg[])
{
unsigned short int len,i;
len = strlen(msg);
for(i=0;i<len;i++)
{
lcddata(msg[i]);
Delay(1);
}
}
Thankyou, With your clear explanation I understand the facts about LCD interfacing. Please upload a session about usage of standard LIBRARIES with keil.
ReplyDeleteThank you for your clear explanation.And I want to know about Gsm interfacing.I hope it will come soon....
ReplyDelete