完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
define uchar unsigned char
***it RS=P2^0; //?????***??????????? ***it RW=P2^1; ***it E=P2^2; ***it led1=P2^3; ***it led2=P2^4; int count,fen,miao,shi,key=0,i,d; uchar c=0; void delay(unsigned int n) //??????? {unsigned int x,y; for(x=0;x void write_command(char com) //д?????????? { E=0; RS=0; RW=0; P1=com; E=1; E=0; delay(1); } void write_data(char dat) //д?????????? { E=0; RS=1; RW=0; P1=dat; E=1; E=0; delay(1); } void lcd_initial(void) //lcd????? { write_command(0x38); write_command(0x0c); write_command(0x06); delay(1); } void string(uchar position,uchar *s) //?????????? { write_command(position); while(*s>0) {write_data(*s++); delay(1); } } /****************************************** ?????????? ???????STC89C52 P2???谴???? S1-4= e7 eb ed ee S5-8= d7 db dd de S9-10= b7 bb bd be S13-16= 77 7b 7d 7e *****************************************/ unsigned char keyscand(void) { unsigned char a,b; P3=0xf0; if((P3&0xf0)!=0xf0) { delay(2); if((P3&0xf0)!=0xf0) { a=P3&0xf0; P3=0x0f; b=P3&0x0f; } } return(a+b); } void main(void) { led1=0; led2=0; lcd_initial();//????????? EA=1; //????? ET0=1; //??????T0?????ж? TMOD=0x01; //T0???1 TH1=(65536-50000)/256;//????????????50ms TL1=(65536-50000)%256; TR0=1; while(1) { key=keyscand(); //???????? switch(key) //?ж???????????????£? { case 0xee: i=0; break; //??????? case 0xde: i=1; break; case 0xbe: i=2; break; case 0x7e: i=3; break; case 0xed: i=4; break; case 0xdd: i=5; break; case 0xbd: i=6; break; case 0x7d: i=7; break; case 0xeb: i=8; break; case 0xdb: i=9; break; case 0xbb: i=10; break; case 0x7b: i=11; break; case 0xe7: i=12; break; case 0xd7: i=13; break; case 0xb7: i=14; break; case 0x77: i=15; break; } if(fen==15&&shi==0||fen==15&&shi==1||fen==15&&shi==2) { led1=1; } if(i==10) { led1=0; delay(10); c++; } if(fen==30&&shi==0||fen==30&&shi==1||fen==30&&shi==2) { led2=1; } if(i==11) { led2=0; d++; delay(10); } } } void timer0() interrupt 1 //?ж? { TH1=(65536-50000)/256; TL1=(65536-50000)%256; count++; //???????????????????1S write_command(0x81); write_data('A'); write_command(0x82); write_data('3'); write_command(0x83); write_data('3'); write_command(0x84); write_data('0'+c); write_command(0x86); write_data('B'); write_command(0x87); write_data('3'); write_command(0x88); write_data('3'); write_command(0x89); write_data('0'+d); write_command(0xce); write_data('6'); write_command(0xcf); write_data('4'); write_command(0xC1); //???shi???λ write_data(0x30+shi/10); write_command(0xC2); //???shi???λ write_data(0x30+shi%10); string(0xC3,":"); write_command(0xC4); //???fen???λ write_data(0x30+fen/10); write_command(0xC5); //???fen???λ write_data(0x30+fen%10); string(0xC6,":"); write_command(0xC7); write_data(0x30+miao/10); write_command(0xC8); write_data(0x30+miao%10); if(count==1) //20ms*50=1S {count=0; miao++;} //?????miao+1 if(miao==60) { miao=0; fen++;} //?????fen+1 if(fen==60) { fen=0; shi++;} if(shi==24) {shi=0;}}
|
|
相关推荐
6个回答
|
|
那肯定是程序没写好了
|
|
|
|
你判断按键抬起了没
|
|
|
|
我已经解决了,把按键的程序弄到中断里就可以了,谢谢大家的帮忙
|
|
|
|
很多人都会出现这样问题的
|
|
|
|
帖子也算是给大家提醒了
|
|
|
|
细心,耐心的啊
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-移植前准备之git管理内核源码
1015 浏览 0 评论
【瑞萨RA2L1入门学习】+ MacOS安装e2studio
450 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-本地仓库管理之分支间的操作
712 浏览 0 评论
【RA-Eco-RA4E2-64PIN-V1.0开发板试用】3D 图形显示
586 浏览 0 评论
697 浏览 1 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
12222 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-28 09:37 , Processed in 0.569951 second(s), Total 83, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号