flashled.c
来自「8051单片机控制LED实现流水灯循环显示」· C语言 代码 · 共 27 行
C
27 行
#include <REGX52.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)
P1 = ~(0x01<<LEDIndex);
else
P1 = ~(0x80>>LEDIndex);
if(LEDIndex==7)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%8;
Delay1ms(100);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?