您的位置 首页 动态

10秒的秒表程序,带暂停

includereg51h>unsignedcharcodeseg7[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}数码管码表unsi

#include

unsigned char code seg7[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}//数码管码表
unsigned char code tab[]={0xfe,0xfd}; //数码管位选
unsigned char cnt=0;//位选变量
unsigned char deta=0,sec=0; //0.01秒变量,和秒变量
sbit stop=P3^3; //暂停
void init() //守时初始化
{
TMOD=0x11;
TH1=0xd8;
TL1=0xf0;
TR1=1;
TH0=0xfc;
TL0=0x18;
TR0=1;
ET1=1;
ET0=1;
EA=1;
}
void time10ms()interrupt 3
{
TH1=0xd8;
TL1=0xf0;
deta++;
}

void show()interrupt 1 //扫描显现2位adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=f63b6e57c5e8b407&k=%CA%FD%C2%EB%B9%DC&k0=%CA%FD%C2%EB%B9%DC&kdi0=0&luki=2&n=10&p=baidu&q=98059059_cpr&rb=0&rs=1&seller_id=1&sid=7b4e8c5576e3bf6&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1831118&u=http%3A%2F%2Fwww%2E51hei%2Ecom%2Fmcu%2F2184%2Ehtml&urlid=0″ id=”0_nwl” mpid=”0″ target=”_blank”>数码管
{
TH0=0xfc;
TL0=0x18;
++cnt;
if(cnt>1)cnt=0;
switch (cnt)
{
case 0: P0=seg7[sec%10];P2=tab[0];break;
case 1: P0=seg7[sec/10];P2=tab[1];break;
default:break;
}
}
void showtime() //时刻显现
{
if((deta>10)&&stop){sec++;deta=0;} //假如P3^3不按下,则为高电平,不暂停时刻。
if(sec==99)sec=0;
}
void main()
{
init();
while(1)
{
showtime();
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/news/dongtai/318470.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部