收藏 分销(赏)

加减-电子时钟的设计.docx

上传人:仙人****88 文档编号:11234862 上传时间:2025-07-09 格式:DOCX 页数:4 大小:11.89KB 下载积分:10 金币
下载 相关 举报
加减-电子时钟的设计.docx_第1页
第1页 / 共4页
加减-电子时钟的设计.docx_第2页
第2页 / 共4页


点击查看更多>>
资源描述
#include<reg52.h> #define uchar unsigned char #define uint unsigned int uchar code duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40,0x00}; uchar shi=0,fen=0,miao=0,count=20; sbit jiakey=P3^2; sbit jiankey=P3^3; sbit xuankey=P3^4; uchar xuanze=0; void delay() { uint i; for(i=0;i<200;i++); } void xianshi() { P2=0; P0=duan[shi/10]; delay(); P2=1; P0=duan[shi%10]; delay(); P2=2; P0=duan[10]; delay(); P2=3; P0=duan[fen/10]; delay(); P2=4; P0=duan[fen%10]; delay(); P2=5; P0=duan[10]; delay(); P2=6; P0=duan[miao/10]; delay(); P2=7; P0=duan[miao%10]; delay(); } void xiugai() { uint i; if(xuankey==0) { for(i=0;i<20000;i++); if(xuankey==0) { xuanze++; if(xuanze>3) xuanze=1; } while(!xuankey); for(i=0;i<20000;i++); } if(jiakey==0) { for(i=0;i<20000;i++); if(jiakey==0) { switch(xuanze) { case 1:shi++; if(shi>23) shi=0; break; case 2:fen++; if(fen>59) fen=0; break; case 3:miao++; if(miao>59) miao=0; break; } } } if(jiankey==0) { for(i=0;i<20000;i++); if(jiankey==0) { switch(xuanze) { case 1:if(shi==0) shi=24; shi--; break; case 2:if(fen==0) fen=60; fen--; break; case 3:if(miao==0) miao=60; miao--; break; } } } } main() { TMOD=0x01; TH0=19644/256; TL0=19644%256; ET0=1; EA=1; TR0=1; while(1) { xianshi(); xiugai(); } } void t0_int()interrupt 1 { TH0=19644/256; TL0=19644%256; count--; if(count==0) { count=20; miao++; if(miao>59) { miao=0; fen++; if(fen>59) { fen=0; shi++; if(shi>23) shi=0; } } } }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服