新聞中心

atmega16與12864

作者: 時(shí)間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
#include

#include
#define uchar unsigned char
#pragma data:code
const uchar string1[]="AVR 單片機(jī)12684 ";
void RDBZ()
{


PORTD&=~BIT(4);
PORTD|=BIT(5);
PORTD&=~BIT(6);
DDRA=0XFF;
PORTA=0XFF;
PORTD|=BIT(6);
DDRA=0X00;
PORTA=0XFF;
while(PINA&0x80);

}
void write_cmd(uchar cmd,uchar buzy)
{

if(buzy)
RDBZ();
DDRA=0XFF;
PORTD&=(~BIT(5)&~BIT(4));
PORTD|=BIT(6);
PORTA=cmd;
PORTD&=~BIT(6);
}
void delay()
{
uchar i;
for(i=0;i<5000;i++);
}
void init()
{
delay();
DDRD=0XFF;


PORTD|=BIT(3);
PORTD&=~BIT(3);
PORTD|=BIT(3);
write_cmd(0x30,0);
delay();
write_cmd(0x30,0);
delay();
write_cmd(0x0C,1);
delay();
write_cmd(0x01,1);
delay();
delay();
write_cmd(0X06,1);
delay();
write_cmd(0X0F,1);
delay();
// write_cmd(0X03,1);
delay();
//write_cmd(0X7A,1);
delay();
}

本文引用地址:http://m.butianyuan.cn/article/201611/321656.htm

void write_dat(uchar dat)
{

RDBZ();
DDRA=0XFF;
PORTD&=~BIT(5);
PORTD|=BIT(6)|BIT(4);
PORTA=dat;
PORTD&=~BIT(6);

}

void main()
{
uchar j;
init();

{

write_cmd(0x90,1);
for(j=0;j<16;j++)
{
write_dat(string1[j]);
}
}
while(1);
}



關(guān)鍵詞: atmega161286

評(píng)論


技術(shù)專區(qū)

關(guān)閉