|
本帖最后由 dzsjzyj 于 2020-5-13 15:33 編輯
#include<reg52.h> //定義單片機頭文件
#include<intrins.h>
#define Led P2
#define uchar unsigned char
#define uint unsigned int
void Timer0Init()
{
TMOD=0X01;
TH0=0XB8;
TL0=0X00;
ET0=1;
EA=1;
TR0=1;
}
void main()
{
Led=0xfe;
Timer0Init();
while(1);
}
void Timer0()interrupt 1
{
uint sec;
TH0=0XB8;
TL0=0X00;
sec++;
if(sec>=50)
{
Led=_crol_(Led,1);
}
}
|
|