完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
#include
***it LSA=P2^2; ***it LSB=P2^3; ***it LSC=P2^4; void delay(unsigned int i); unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40}; unsigned char shi,miao,fen,time,ledout[8]; void main() { unsigned char i; TMOD=0x01; TH0=0x3c; TL0=0x0b; EA=1; ET0=1; TR0=1; IT0=1; EX0=1; IT1=1; EX1=1; EA=1; while(1) { ledout[0]=table[shi/10]; ledout[1]=table[shi%10]; ledout[2]=table[fen/10]; ledout[3]=table[fen%10]; ledout[4]=table[miao/10]; ledout[5]=table[miao%10]; ledout[6]=0x3f; ledout[7]=0x3f; for(i=0;i<8;i++) { P0=ledout[i]; switch(i) { case 0: LSA=0;LSB=0;LSC=0;break; case 1: LSA=0;LSB=0;LSC=1;break; case 2: LSA=0;LSB=1;LSC=0;break; case 3: LSA=0;LSB=1;LSC=1;break; case 4: LSA=1;LSB=0;LSC=0;break; case 5: LSA=1;LSB=0;LSC=1;break; case 6: LSA=1;LSB=1;LSC=0;break; case 7: LSA=1;LSB=1;LSC=1;break; } delay(150); } } } void delay(unsigned int i) { char j; for(i;i>0;i--) for(j=200;j>0;j--); } void time1() interrupt 0 using 1 { EX0=0; shi++; if(shi==24) shi=0; EX0=1; } void time2() interrupt 2 using 2 { EX0=0; fen++; if(fen==60) fen=0; EX0=1; } void time3() interrupt 1 { TH0=0x3c; TL0=0x0b; time++; if(time==20) { time=0; miao++; if(miao==60) { miao=0; fen++; if(fen==60) { fen=0; shi++; if(shi==24) { shi=0; } } } } } |
|
相关推荐
2 个讨论
|
|
|
|
|
|
|
|
|
|
|
准备做一个电子diy将太阳能和led结合起来,大家有什么好的创意吗?
3597 浏览 0 评论
24618 浏览 180 评论
1658 浏览 0 评论
5808 浏览 1 评论
分享一个比较好的编码器模式的程序 自己曾经做过倒立摆的程序 亲测好用
9573 浏览 24 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-3 14:50 , Processed in 0.761842 second(s), Total 49, Slave 36 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
7390