proteus 1602液晶程序
#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
}
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);
}
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液 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)