原工程文件 https://download.csdn.net/download/m0_48459378/23960209
代码:
/*
*流水灯左移*
*/
#include <reg51.h> //头文件
typedef unsigned char uint8;
typedef unsigned int uint16;
void main()
{
uint8 j = 0;
uint16 i;
while(1)
{
P0 = ~(0x01 << j++); //00000001 00000010 11111101
for(i = 0;i< 20000;i++);
if(8 == j)
{
j = 0;
}
}
}
效果:实现流水灯的效果