欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
999秒倒計(jì)時(shí)單片機(jī)程序
[打印本頁(yè)]
作者:
caojiaquan
時(shí)間:
2018-1-29 11:52
標(biāo)題:
999秒倒計(jì)時(shí)單片機(jī)程序
#include <reg52.h>
sbit wei3=P3^6; /*百位*/
sbit wei1=P3^4; /*個(gè)位*/
sbit wei2=P3^5; /*十位*/
unsigned char code LedChar[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E };
void delay(int z);
unsigned char i=0; //動(dòng)態(tài)掃描的索引
unsigned int cnt=0; //記錄 T0 中斷次數(shù)
void main()
{ unsigned long sec=0;
EA=1; //使能總中斷
TMOD=0x01; //設(shè)置 T0 為模式 1
TH0=0xB8; //為 T0 賦初值 0xFC67,定時(shí) 1ms
TL0=0x00;
ET0=1; //使能 T0 中斷
TR0=1; //啟動(dòng) T0
while (1)
{
if (cnt>=1000) //判斷 T0 溢出是否達(dá)到 1000 次
{ cnt=0; //達(dá)到 1000 次后計(jì)數(shù)值清零
sec++; //秒計(jì)數(shù)自加 1
}
wei1=0;
P0=LedChar[sec%10];delay(5);P0=0xff;
wei1=1; wei2=0;P0=LedChar[sec/10%10];delay(5); P0=0xff;wei2=1;
wei3=0;P0=LedChar[sec/100%10];delay(5); P0=0xff;wei3=1;
if(sec>999)
{
sec=0;
}
/*wei1=1;
delay(5);
wei2=0;
P0=LedChar[sec/10%10];
wei2=1;
delay(5);
wei3=0;
P0=LedChar[sec/100%10];
wei3=1;
delay(5);
if(sec>999)
{ sec=0; } */
}
}
void delay(int z)
{ int x,y;
for(x=z;x>0;x--)
for(y=10;y>0;y--);
}
/* 定時(shí)器 0 中斷服務(wù)函數(shù) */
void InterruptTimer0() interrupt 1
{ TH0 = 0xFC; //重新加載初值
TL0 = 0x67;
cnt++; //中斷次數(shù)計(jì)數(shù)值加 1
}
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1