新聞中心

單片機(jī)LCD顯示屏

作者: 時(shí)間:2016-11-21 來(lái)源:網(wǎng)絡(luò) 收藏
電路圖:
代碼如下:
#include
#include
sbit RS=0xA0;
sbit RW=0xA1;
sbit E=0xA2;
void lcd_w_cmd(unsigned char com);
void lcd_w_dat(unsigned char dat);
unsigned char lcd_r_start();
void init();
void delay(unsigned char t);
void delay1();
void GONG_ZI()
{
lcd_w_cmd(0x40);
lcd_w_dat(0x1f);
lcd_w_cmd(0x41);
lcd_w_dat(0x1f);
lcd_w_cmd(0x42);
lcd_w_dat(0x04);
lcd_w_cmd(0x43);
lcd_w_dat(0x04);
lcd_w_cmd(0x44);
lcd_w_dat(0x04);
lcd_w_cmd(0x45);
lcd_w_dat(0x1f);
lcd_w_cmd(0x46);
lcd_w_dat(0x1f);
lcd_w_cmd(0x47);
lcd_w_dat(0x00);
}
void main()
{
unsigned char lcd[]="cgyl2010!!";
unsigned char lcd1[]="linux kernel!!";
unsigned char i;
P0=0xff;
init();
delay(255);
delay(255);
lcd_w_cmd(0x83);
delay(255);
for(i=0;i<10;i++)
{
lcd_w_dat(lcd[i]);
delay(200);
}
lcd_w_cmd(0xc1);
delay(255);
for(i=0;i<14;i++)
{
lcd_w_dat(lcd1[i]);
delay(200);
}
while(1);
}
void delay(unsigned char t)
{
unsigned char j,i;
for(i=0;i
for(j=0;j<50;j++);
}
void delay1()
{
_nop_();
_nop_();
_nop_();
}
void init()
{
lcd_w_cmd(0x3c);
lcd_w_cmd(0x0e);
lcd_w_cmd(0x01);
lcd_w_cmd(0x06);
lcd_w_cmd(0x80);
}
unsigned char lcd_r_start()
{
unsigned char s;
RW=1;
delay1();
RS=0;
delay1();
E=1;
s=P0;
delay1();
E=0;
delay1();
RW=0;
delay1();
return s;
}
void lcd_w_cmd(unsigned char com)
{
unsigned char i;
do{
i=lcd_r_start();
i=i&0x80;
delay(2);
}while(i!=0);
RW=0;
delay1();
RS=0;
delay1();
E=1;
delay1();
P0=com;
delay1();
E=0;
delay1();
RW=1;
delay(255);
}
void lcd_w_dat(unsigned char dat)
{
unsigned char i;
do{
i=lcd_r_start();
i=i&0x80;
delay(2);
}while(i!=0);
RW=0;
delay1();
RS=1;
delay1();
E=1;
delay1();
P0=dat;
delay1();
E=0;
delay1();
RW=1;
delay(255);
}



關(guān)鍵詞: 單片機(jī)LCD顯示

評(píng)論


技術(shù)專區(qū)

關(guān)閉