单片机+1602液晶显示设计
忙了一天做了一个1602 显示的仿真电路和程序 经过调试正常运行!!Success的感觉真好 哈哈.........
现在就把成果分享给大家
本电路程序如下:#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);//显示模式设置 设定1602*2显示 5*7点阵 8为数据入口write_cmd(0x0c);//显示开关、光标设置 0x0f可以显示光标write_cmd(0x04);//光标机屏幕显示设方式置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); //动态停机}如果需要动态移动还可以再加上一条屏幕移动指令for(num=0;num16;num++){write_cmd(0x1f);delay(8000);}
pid控制相关文章:pid控制原理
评论