LED在定时器的中断控制下不断闪烁(0.5S开关一次),程序怎么编,急!急!急!
1个回答
展开全部
#include <REG51.H>
#define uchar unsigned char
sbit LED =P1^1;
uchar time;
void init_t0int()
{
TMOD=0x01;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void main()
{
init_t0int();
while(1);
}
void t0int() interrupt 1
{
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
time++;
if(time==5)
{
time=0;
LED=~LED;
}
}
#define uchar unsigned char
sbit LED =P1^1;
uchar time;
void init_t0int()
{
TMOD=0x01;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void main()
{
init_t0int();
while(1);
}
void t0int() interrupt 1
{
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
time++;
if(time==5)
{
time=0;
LED=~LED;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询