#include <REGX52.H>
void Delay1ms(unsigned int xms) //@12.000MHz
{
unsigned char i, j; //定义xms为无符号整型
while(xms)
{
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
xms--; //xms=xms-1
}
}
void main()
{
while(1)
{
P2=0xfe;
Delay1ms(500); //1111 1110 //延迟500ms
P2=0xfd;
Delay1ms(400); //1111 1101 //延迟400ms
P2=0xfb;
Delay1ms(300); //1111 1011 //延迟300ms
P2=0xf7;
Delay1ms(250); //1111 0111 //延迟250
P2=0xef;
Delay1ms(150); //1110 1111 //延迟150
P2=0xdf;
Delay1ms(100); //1101 1111 //延迟100
P2=0xbf;
Delay1ms(100); //1011 1111 //延迟100
P2=0x7f;
Delay1ms(100); //0111 1111 //延迟100
}
}
基于51单片机 led流水灯,随意控制每个灯时间
最新推荐文章于 2023-02-22 20:01:13 发布