?? miao biao.txt
字號:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, 0x7f,0x6f};
uchar sec; //定義計數(shù)值,每過1 秒,sec 加1
uint tcnt; //定時中斷次數(shù)
sbit gewei=P2^0; //個位選通定義
sbit shiwei=P2^1; //十位選通定義
void Delay(uint tc) //延時程序
{
while( tc != 0 )
{
uint i;
for(i=0; i<100; i++);
tc--;
}
}
void LED() //LED 顯示函數(shù)
{
shiwei=0; P0=table[sec%10]; Delay(5); shiwei=1;
gewei=0; P0=table[sec/10]; Delay(8); gewei=1;
}
void t0(void) interrupt 1 using 0 //定時中斷服務(wù)函數(shù)
{
TH0=(65536-50000)/256; //對TH0 TL0 賦值
TL0=(65536-50000)%256; //重裝計數(shù)初值
tcnt++; //每過250ust tcnt 加一
if(tcnt==20) //計滿20 次(1 秒)時
{
tcnt=0;
sec++;
if(sec==60)
{
sec=0;
}
}
}
void main(void)
{
P2=0;
TMOD=0x01; //定時器工作在方式1
ET0=1; EA=1;
TH0=(65536-50000)/256; //對TH0 TL0 賦值
TL0=(65536-50000)%256; //使定時器0.05 秒中斷一次
TR0=1; //開始計時
while(1)
{
LED();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -