久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > 嵌入式系統 > 設計應用 > AVR 1602液晶字符移動

AVR 1602液晶字符移動

作者: 時間:2016-11-30 來源:網絡 收藏
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar str1[16]="This is a ASCII";
uchar str2[16]=" Test ";
#include "1602.h"
void port_init()
{
PORTA=0xff;
DDRA=0xff;
PORTB=0xff;
DDRB=0xff;
PORTD=0xff;
DDRD=0xff;
}
void init()
{
MCUCR=0x0a;
GICR=0xc0;
SREG=0x80;
}
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

}
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);
//初始化結束
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;
}
}

//-----------------1602庫函數-----------------------
#define RS PORTB_Bit0
#define RW PORTB_Bit1
#define EN PORTB_Bit2
#define DATA PORTA
#define busy 0x80

上一頁 1 2 下一頁

評論


技術專區

關閉