Microcontroller › 8051 › CHECK OUT MY C PROGRAM ON LCD AS THERE IS LITTLE MISTAKE › lalchand oad 10ES30 Quaid e
lalchand oad 10ES30 Quaid e awam university of engineering science and technology nawabshah sindh pakistan
First define funtions befor void main() as :
#include <reg51.h>
void lcd_cmd(unsigned char value);
void MSdelay(unsigned int itime);
void lcd_data(unsigned char value);
sfr ldata=0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
void main()
{
lcd_cmd(0x38);
MSdelay(250);
lcd_cmd(0x0E);
MSdelay(250);
lcd_cmd(0x1);
MSdelay(250);
lcd_cmd(0x06);
MSdelay(250);
lcd_cmd(0x86);
MSdelay(250);
lcd_data(‘M’); // DATA
MSdelay(250);
lcd_data(‘D’);
MSdelay(250);
lcd_data(‘E’);
}
void lcd_cmd(unsigned char value)
{
ldata=value;
rs=0;
rw=0;
en=1;
MSdelay(1);
en=0;
return;
}
void lcd_data(unsigned char value)
{
ldata=value;
rs=1;
rw=0;
en=1;
MSdelay(1);
en=0;
return;
}
void MSdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0; i<itime; i++)
for (j=0; j<1275; j++);
}