萌新求一个程序用51单片机点亮一个led延时10秒后熄灭求大神写一下或者是10秒后灯亮也可以

如题所述

// 12MHz晶振
#include<reg51.h>
sbit LED=P1^0; //LED接P1.0
unsigned int cnts_per250us;
void main( )
{
LED=LED;
EA=1;
ET0=1;
TMOD=0x02; // 自动重装模式
TH0=TL0=6;
TR0=1;
while(1);
}
void t0() interrupt 1
{
if ( ++cnts_per250us==40000)
{
LED=~LED;
cnts_per250us=0;
}
}
温馨提示:答案为网友推荐,仅供参考
相似回答