展开全部
FYI,试一下
#include <reg52.h>
sbit VD0 = P1^0;
sbit VD1 = P1^1;
sbit VD2 = P1^2;
sbit VD3 = P1^3;
sbit VD4 = P1^4;
sbit VD5 = P1^5;
sbit VD6 = P1^6;
sbit VD7 = P1^7;
void Delay400ms(); //函数声明
void main()
{
P1 = 0XFF; //初始化,开始全灭,注意不是1,是0XFF
while (1)
{
//外往内
VD0 = VD7 = 0;
Delay400ms(); //调用延时函数
P1 = 0XFF; //重置P1
Delay400ms();
VD1 = VD6 = 0;
Delay400ms();
P1 = 0XFF;
Delay400ms();
VD2 = VD5 = 0;
Delay400ms();
P1 = 0XFF;
Delay400ms();
VD3 = VD4 = 0;
Delay400ms();
P1 = 0XFF;
Delay400ms();
//内往外
VD2 = VD5 = 0;
Delay400ms();
P1 = 0XFF;
Delay400ms();
VD1 = VD6 = 0;
Delay400ms();
P1 = 0XFF;
Delay400ms();
}
}
void Delay400ms() //@12.000MHz
{
unsigned char i, j, k;
i = 4;
j = 11;
k = 45;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询