帮我写个51单片机点灯程序吧,用c语言来实现
时间: 2023-03-09 11:49:04 浏览: 226
好的,我可以尝试写一个点灯程序给你:
#include <reg51.h>
unsigned int cnt; void main()
{
cnt = 0;
TMOD = 0x01;
TH0 = 0xFC;
TL0 = 0x67;
EA = 1;
ET0 = 1;
TR0 = 1;
while (1)
{
if(cnt == 20)
{
P1 = ~P1;
cnt = 0;
}
}
} void Timer0() interrupt 1
{
TH0 = 0xFC;
TL0 = 0x67;
cnt++;
}
相关问题
写个c语言的单片机点灯程序
我可以给你一个简单的例子:
#include <reg51.h>
sbit LED=P1^0;
void delay(unsigned int x)
{
while(x--);
}
void main()
{
while(1)
{
LED=0;
delay(50000);
LED=1;
delay(50000);
}
}
用C语言写一个51单片机点灯代码
#include <reg51.H>
sbit LED = P1^0;
void main()
{
while(1)
{
LED = 0;
delay(1000);
LED = 1;
delay(1000);
}
}
阅读全文