完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
#include "reg51.h"
#define uchar unsigned char #define uint unsigned int ***it P0_4=P0^4; ***it P0_5=P0^5;//按键 uchar duan[]={0xc0,0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90}; uchar wei[]={0x02,0x01}; uint count=0; void delay(uint t)//延时函数 { uint i,j; for(i=0;i } void time()//定时器 { TH1=0x3c; TL1=0xb0;//50ms TR1=1; while(!TF1); } void zhongduan1()interrupt 3//中断子程序 { uchar i; TH1=0x3c; TL1=0xb0; i++; if(i>3) { i=0; if(P0_4==0) { count++; if(count>60) count=0; } if(P0_5==0) { if(count>0) count--; else count=0; } } } void shuma(uchar num1,uchar num2)//数码管显示函数 { P2=~wei[num2]; P1=~duan[num1]; delay(20); } void main() { uchar tab[2]; TMOD=0x10;//T1工作方式1 EA=1; ET1=1; while(1) { tab[0]=count/10; tab[1]=count%10; shuma(tab[1],0); shuma(tab[0],1); TR1=1;//中断请求标志位 } } 怎样改改,可以使当按键一直按下去的时候,只使数加一,而不是一直加。 |
|
相关推荐
5 个讨论
|
|
你正在撰写讨论
如果你是对讨论或其他讨论精选点评或询问,请使用“评论”功能。
【瑞萨RA6E2】瑞萨E2S软件安装过程,等待过程玩下97_e2 studio_ZGZZ
234 浏览 0 评论
514 浏览 0 评论
【原创】【RA4M2-SENSOR开发板评测】低功耗+USB综合测试
826 浏览 0 评论
1366 浏览 2 评论
814 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
16911 浏览 31 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-3 02:56 , Processed in 0.541706 second(s), Total 45, Slave 38 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1677