#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcdrs=P0^0;
sbit lcdrw=P0^1;
sbit lcden=P0^2;
#define lcd_date P0
uchar code table1[]=" stckuj ";
uchar code table2[]=" wwtyinu ";
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void Lcd_1602_write_com(uchar com)
{
delay(20);
lcdrw=0;
lcdrs=0;
lcden=0;
delay(20);
lcd_date=(com&0xf0);
delay(20);
lcden=1;
delay(20);
lcden=0;
lcd_date=(com&0x0f)<<4;
delay(20);
lcden=1;
delay(20);
lcden=0;
}
void Lcd_1602_write_date(uchar date)
{
delay(20);
lcdrw=0;
lcden=0;
lcdrs=1;
delay(20);
lcd_date=(date&0xf0);
delay(20);
lcden=1;
delay(20);
lcden=0;
lcd_date=(date&0x0f)<<4;
delay(20);
lcden=1;
delay(20);
lcden=0;
delay(20);
}
void Lcd_1602_init()
{
lcd_date=0;
delay(20);
Lcd_1602_write_com(0x28);
delay(20);
Lcd_1602_write_com(0x28);
delay(20);
Lcd_1602_write_com(0x28);
delay(20);
Lcd_1602_write_com(0x28);
delay(20);
Lcd_1602_write_com(0x0c);
delay(20);
Lcd_1602_write_com(0x06);
delay(20);
Lcd_1602_write_com(0x01);
delay(20);
}
void main()
{
uchar num;
Lcd_1602_init();
Lcd_1602_write_com(0x80);
for(num=0;num<16;num++)
{
Lcd_1602_write_date(table1[num]);
delay(20);
}
Lcd_1602_write_com(0xc0);
for(num=0;num<16;num++)
{
Lcd_1602_write_date(table2[num]);
delay(20);
}
while(1);
}
此帖出自
小平头技术问答
可以的,那非常感谢,我参考学习一下。我邮箱:18811707971@163.com
谢谢
一周热门 更多>