單片機(jī)+1602液晶顯示設(shè)計(jì)
忙了一天做了一個(gè)1602 顯示的仿真電路和程序 經(jīng)過(guò)調(diào)試正常運(yùn)行!!Success的感覺(jué)真好 哈哈.........
現(xiàn)在就把成果分享給大家
本電路程序如下:#includereg51.h>#includestdio.h>#define uint unsigned int#define uchar unsigned charuchar code tab[]="Hello Jary!";uchar code tab1[]="I Love You!";uchar num,len,len1;sbit RS=P2^5;sbit RW=P2^6;sbit EN=P2^7;void delay(uint x){while(--x);}void write_cmd(uchar cmd){RS=0;RW=0;P0=cmd;delay(50);EN=1;delay(50);EN=0;}void write_dat(uchar dat){RS=1;RW=0;P0=dat;delay(50);EN=1;delay(50);EN=0;}void inti_lcd()//1602初始化{EN=0;write_cmd(0x38);//顯示模式設(shè)置 設(shè)定1602*2顯示 5*7點(diǎn)陣 8為數(shù)據(jù)入口write_cmd(0x0c);//顯示開(kāi)關(guān)、光標(biāo)設(shè)置 0x0f可以顯示光標(biāo)write_cmd(0x04);//光標(biāo)機(jī)屏幕顯示設(shè)方式置write_cmd(0x01);//清屏write_cmd(0x80);//指針初始化}void main(){inti_lcd();len=sizeof(tab);len1=sizeof(tab1);write_cmd(0x80+0x02);for(num=0;numlen;num++){write_dat(tab[num]);delay(6);}write_cmd(0x80+0x45);for(num=0;numlen1;num++){write_dat(tab1[num]);delay(6);}while(1); //動(dòng)態(tài)停機(jī)}如果需要?jiǎng)討B(tài)移動(dòng)還可以再加上一條屏幕移動(dòng)指令for(num=0;num16;num++){write_cmd(0x1f);delay(8000);}
pid控制相關(guān)文章:pid控制原理
評(píng)論