欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
基于51單片機(jī)做的一個(gè)24小時(shí)時(shí)鐘程序 內(nèi)含清零和暫停功能
[打印本頁(yè)]
作者:
tigerboom
時(shí)間:
2018-11-29 18:50
標(biāo)題:
基于51單片機(jī)做的一個(gè)24小時(shí)時(shí)鐘程序 內(nèi)含清零和暫停功能
內(nèi)含清零和暫停功能
0.png
(11.84 KB, 下載次數(shù): 19)
下載附件
2018-12-1 02:01 上傳
單片機(jī)源程序如下:
#include<reg51.h>
unsigned char seg_data[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf}; //8段數(shù)碼管顯示代碼,最后一位0xbf為橫線
unsigned char position[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; //選位端循環(huán)
int sum_position=0;
int text=0;
int s1=0,s2=0,m1=0,m2=0,h1=0,h2=0; //定義秒、分、時(shí)
sbit pause=P3^3; //清零鍵
unsigned int sum;
void delaytime(unsigned int x); //聲明調(diào)用函數(shù)‘延時(shí)’
void diaplayscreen(unsigned int n); //聲明調(diào)用函數(shù)‘顯示’
void main()
{
//打開(kāi)中斷(暫停)
EA=1;EX0=1;IT0=1;
while(1)
{
if(s1==9&&s2==5&&m1==9&&m2==5&&h1==3&&h2==2)
{s1=0;s2=0;m1=0;m2=0;h1=0;h2=0; } //清零
s1++; //秒+1
if(s1>9) //計(jì)時(shí)‘秒’
{
s1=0;
s2++;
}
if(s2>5)
{
s2=0;
m1++;
}
if(m1>9) //計(jì)時(shí)‘分’
{
m1=0;
m2++;
}
if(m2>5)
{
m2=0;
h1++;
}
if(h1>9) //計(jì)時(shí)‘時(shí)’
{
h1=0;
h2++;
}
/******8位LED顯示******/
if(text==0)
{
for(sum=0;sum<62;sum++) //‘sum’調(diào)節(jié)1s時(shí)長(zhǎng)(可加變量x調(diào)節(jié))
{ //顯示時(shí)間
diaplayscreen(s1);
diaplayscreen(s2);
diaplayscreen(10);
diaplayscreen(m1);
diaplayscreen(m2);
diaplayscreen(10);
diaplayscreen(h1);
diaplayscreen(h1);
if(sum_position==8) //置零選位端
sum_position=0;
}
}
else
{
while(1) //無(wú)限循環(huán)顯示
{
diaplayscreen(s1);
diaplayscreen(s2);
diaplayscreen(10);
diaplayscreen(m1);
diaplayscreen(m2);
diaplayscreen(10);
diaplayscreen(h1);
diaplayscreen(h1);
if(sum_position==8)
sum_position=0;
if(text==0) //暫停結(jié)束
break;
}
}
if(pause==0)
{s1=-1;s2=0;m1=0;m2=0;h1=0;h2=0;}
}
}
void diaplayscreen(unsigned int n) //顯示函數(shù)
{
P2=position[sum_position];//先選位在輸入
P0=seg_data[n];
delaytime(1);
sum_position++;
}
void delaytime(unsigned int x) //延時(shí)函數(shù),最小精度1毫秒
{
unsigned char j;
while(x--)
{
for(j=0;j<200;j++)
{;}
}
}
void zero() interrupt 0 //暫停
{
//s1=0;s2=0;m1=0;m2=0;h1=0;h2=0;
text=~text;
}
復(fù)制代碼
所有資料51hei提供下載:
24小時(shí)計(jì)時(shí)器.rar
(83.56 KB, 下載次數(shù): 19)
2018-11-29 18:49 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
1498847856
時(shí)間:
2019-7-3 12:21
挺好啊
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1