05_LED流水灯Plus

发布时间 2023-11-04 14:55:41作者: 爱吃冰激凌的黄某某

LED流水灯Plus

image-20231102153850475

修改延迟函数

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

修改代码

#include <REGX52.H>

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

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

效果

VID_20231102_160855