Proteus:单片机定时器中断(LED闪烁)

题目概述:
单片机定时器中断(LED闪烁)。
编程:
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit LED=P0^0;
void Time()
{
TMOD=0x01;//00000 0001定时器0工作方式1
TF0=0;
TR0=1;
TH0=64535/256;//高八位
TL0=64535%256;//低八位
ET0=1;
EA=1;
PT0=0;
}
void main()
{
Time();
while(1)
{

}
}
uint count;
void Time0() interrupt 1
{

TH0=64535/256;//重置时间
TL0=64535%256;
count++;
if(count>=100)
{
count=0;
LED=~LED;
}
模拟实践:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_50426849/article/details/119486911