在proteus上模拟LCD,但一直不能显示C:\Users\马大壮\Desktop
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define LCD_DB P3
sbit LCD_RW=P2^1;
sbit LCD_RS=P2^0;
sbit LCD_EN=P2^3;
uchar code table[]="I LOVE YOU!";
uchar num;
void delay(uchar z)
{
uint x,y;
for(y=z;y>0;y--)
for(x=110;x>0;x--);
}
/************ LCD COMMOND ********/
void LCD_write_com(uchar com)
{
LCD_RS=0;
LCD_DB=com;
delay(5);
LCD_EN=1;
delay(5);
LCD_EN=0;
}
/********** LCD DATA *************/
void LCD_write_dat(uchar dat)
{
LCD_RS=1;
LCD_DB=dat;
delay(5);
LCD_EN=1;
delay(5);
LCD_EN=0;
}
/************ LCD INIT ************/
void LCD_Init()
{
LCD_EN=0;
LCD_write_com(0x38);
LCD_write_com(0x0e);
LCD_write_com(0x06);
LCD_write_com(0x01);
// LCD_write_com(0x80+0x10);
}
////////////////////////////////////////
void main()
{
LCD_RW=0;
LCD_Init();
for(num=0;num<11;num++)
{
LCD_write_dat(table[num]);
delay(600);
}
while(1);
}
|