您的位置 首页 电子

单片机LCD显示屏

电路图:代码如下:#includereg51.h>#includeINTRINS.H>sbitRS=0xA0;sbitRW=0xA1;sbitE=0xA2;voidlcd_w_cmd(un

电路图:

代码如下:
#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);
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/dianzi/262782.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部