新闻中心

EEPW首页>嵌入式系统>设计应用> proteus 1602液晶程序

proteus 1602液晶程序

作者: 时间:2016-11-13 来源:网络 收藏
proteus1602液晶是LM016L

#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
#pragma data:code
const uchar table[]="I LOVE CHINA";
const uchar table1[]="MADE BY LYQ" ;
void delay(uint ms)
{
uint i,j;
for(i=0;i for(j=0;j<1141;j++);
}
void write_com(uchar com)
{
PORTD&=~BIT(4); // RS
PORTD&=~BIT(5);// RW
PORTB=com;
//PORTD&=~BIT(6);// E
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);

}

本文引用地址://m.amcfsurvey.com/article/201611/316375.htm

void write_data(uchar data)
{
PORTD|=BIT(4); // RS
PORTD&=~BIT(5);// RW
PORTB=data;
//PORTD&=~BIT(6);// E
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);
}

void main()
{
uchar i;
DDRB=0XFF;
DDRD|=BIT(4)|BIT(5)|BIT(6);
PORTD&=~BIT(6);

write_com(0x38);
delay(5);
write_com(0x01);//clear screen//清屏命令非常重要,没有出现乱码
delay(5);
write_com(0x0f);
delay(5);
write_com(0x06);
delay(5);
write_com(0x80+0x10);
delay(5);

for(i=0;i<12;i++)
{
write_data(table[i]);
delay(1);
}
write_com(0x80+0x40+0x10);
delay(5);

for(i=0;i<11;i++)
{
write_data(table1[i]);
delay(1);
}
delay(1000);
for(i=0;i<16;i++)
{
write_com(0x1c);//屏幕左移16次,不是0x18
delay(200);

}

}



关键词:proteus1602液

评论


技术专区

关闭