求高人给写一个8位流水灯的C语言程序,越简单越好,在线等,谢了

如题所述

#include <REG51.H>
void Delay1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++);
}

main()
{
unsigned char LEDIndex = 0;
bit LEDDirection = 1;
while(1)
{
if(LEDDirection)
P2 = ~(0x01<<LEDIndex);
else
P2 = ~(0x80>>LEDIndex);
if(LEDIndex==7)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%8;
Delay1ms(500);
}
}
温馨提示:答案为网友推荐,仅供参考
相似回答