单片机LCD显示屏
![](../img/eep/emb/emb-59016fikpbjvmi1q.jpg)
代码如下:
#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); }
单片机LCD显示 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)