首页 > 其他分享 >STC89C52单片机实现LED流水灯PLUS

STC89C52单片机实现LED流水灯PLUS

时间:2022-10-29 17:31:44浏览次数:47  
标签:P2 LED STC89C52 Delay1ms 1111 单片机 while 500 xms


修改计时代码已实现可以自由设定闪烁间隔时间

#include <REGX52.H>

void Delay1ms(unsigned int xms) //@12.000MHz
{
unsigned char i, j;
while(xms)
{
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
xms=xms-1;
}

}

void main()
{
while(1)
{
P2=0xFE; //1111 1110
Delay1ms(500);
P2=0xFD; //1111 1101
Delay1ms(500);
P2=0xFB; //1111 1011
Delay1ms(500);
P2=0xF7; //1111 0111
Delay1ms(500);
P2=0xEF; //1110 1111
Delay1ms(500);
P2=0xDF; //1101 1111
Delay1ms(500);
P2=0xBF; //1011 1111
Delay1ms(500);
P2=0x7F; //0111 1111
Delay1ms(500);
}
}

STC89C52单片机实现LED流水灯PLUS_51单片机

标签:P2,LED,STC89C52,Delay1ms,1111,单片机,while,500,xms
From: https://blog.51cto.com/nclx/5806277

相关文章