欢迎来到天天文库
浏览记录
ID:41312311
大小:883.50 KB
页数:10页
时间:2019-08-21
《实验显示姓名学号》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#defineuintunsignedint#defineucharunsignedcharsbitlcdrs=P1^5;sbitlcdrw=P1^6;sbitlcden=P1^7;sbitle=P1^2;sbitkey1=P3^3;sbitkey2=P3^4;sbitkey3=P3^5;sbitkey4=P3^6;ucharcodeb1[]="zhangwen";ucharcodeb2[]="65100300";uinti;ucharaa;voiddelay(uintz){uint
2、x,y;for(x=100;x>1;x--)for(y=z;y>1;y--);}voidwrite_com(ucharcom){lcdrs=0;lcdrw=0;lcden=0;P0=com;delay(5);lcden=1;delay(5);lcden=0;}voidwrite_date(uchardate){lcdrs=1;lcdrw=0;lcden=0;P0=date;delay(5);lcden=1;delay(5);lcden=0;}voidinit_lcd(){lcden=0;lcdrw=0;write_com(0x38);write_com(
3、0x0c);write_com(0x06);write_com(0x01);write_com(0x80);for(i=0;i<16;i++){write_date(b1[i]);delay(0);}delay(5);write_com(0xc0);for(i=0;i<16;i++){write_date(b2[i]);delay(0);}}voidkey(){if(key1==0){delay(5);if(key1==0){le=1;aa=0xfc;for(i=0;i<8;i++){P0=aa;aa=_crol_(aa,1);delay(1000);}
4、le=0;}}if(key2==0){delay(5);if(key2==0){le=1;aa=0x7f;for(i=9;i>0;i--){P0=aa;aa=_irol_(aa,1);delay(1000);}le=0;}}if(key3==0){delay(5);if(key3==0){write_com(0x80);for(i=0;i<16;i++){write_date(b1[i]);delay(0);}write_com(0x80+0x40);for(i=0;i<16;i++){write_date(b2[i]);delay(0);}}}if(k
5、ey4==0){delay(5);if(key4==0){write_com(0x80);for(i=16;i>0;i--){write_date(b2[i]);delay(0);}write_com(0x80+0x40);for(i=16;i>0;i--){write_date(b1[i]);delay(0);}}}}voidmain(){le=0;init_lcd();while(1){key();}}
此文档下载收益归作者所有