#include
#include
#define uchar unsigned char
#define uint unsigned int
#define uint unsigned int
uchar str1[16]=”This is a ASCII”;
uchar str2[16]=” Test “;
uchar str2[16]=” Test “;
#include “1602.h”
void port_init()
{
PORTA=0xff;
DDRA=0xff;
PORTB=0xff;
DDRB=0xff;
PORTD=0xff;
DDRD=0xff;
}
{
PORTA=0xff;
DDRA=0xff;
PORTB=0xff;
DDRB=0xff;
PORTD=0xff;
DDRD=0xff;
}
void disline(uchar w) //字符移动函数
{
uchar i;
for(i=0;i<16;i++)
{
displayonechar(i,1,w); //字符显现在第二行 即字母A–Z
w++;
if(w>90)w=65; //字符显现限制规模A–Z
{
uchar i;
for(i=0;i<16;i++)
{
displayonechar(i,1,w); //字符显现在第二行 即字母A–Z
w++;
if(w>90)w=65; //字符显现限制规模A–Z
}
delay(500);
}
void main()
{
uchar w=65;
port_init();
init();
//1602设备初始化
delay(15);
writecmd(0x38);
delay(5);
writecmd(0x38);
delay(5);
writecmd(0x38);
writecmd(0x80);
writecmd(0x01);
writecmd(0x06);
writecmd(0x0c);
delay(500);
//初始化完毕
{
uchar w=65;
port_init();
init();
//1602设备初始化
delay(15);
writecmd(0x38);
delay(5);
writecmd(0x38);
delay(5);
writecmd(0x38);
writecmd(0x80);
writecmd(0x01);
writecmd(0x06);
writecmd(0x0c);
delay(500);
//初始化完毕
writecmd(0x01);
writecmd(0x0c);
displaychar(0,0,str1);
delay(1000);
writecmd(0x01);
writecmd(0x0c);
displaychar(0,1,str2);
delay(1000);
writecmd(0x01);
writecmd(0x0c);
while(1)
{
disline(w++); //字符移动形式
if(w>90)w=65;
}
}
writecmd(0x0c);
displaychar(0,0,str1);
delay(1000);
writecmd(0x01);
writecmd(0x0c);
displaychar(0,1,str2);
delay(1000);
writecmd(0x01);
writecmd(0x0c);
while(1)
{
disline(w++); //字符移动形式
if(w>90)w=65;
}
}
//—————–1602库函数———————–
#define RS PORTB_Bit0
#define RW PORTB_Bit1
#define EN PORTB_Bit2
#define DATA PORTA
#define busy 0x80
#define RW PORTB_Bit1
#define EN PORTB_Bit2
#define DATA PORTA
#define busy 0x80
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/adas/318358.html