我觉得这个灯应该是在12两个位置来回亮,请问为什么是第一个灯一直亮呢


#include<reg51.h>
#include<intrins.h>
void delay(unsigned int i)
{
  unsigned char t = 0;
  while(i--)
  {
    for(t = 0;t < 120; t++);
  }
}
void main()
{
unsigned char temp;
P2=0xff;
while(1)
{
P1=0x01;
temp=P2;
temp=temp&0x03;
switch(temp)
{
case 0:P1=~P1,delay(500),P1=_crol_(P1,1);break;
//P1进行了一个移位变化,再跳出switch继续循环
}
}
}

img

case 0:P1=~P1,delay(500),P1=crol(P1,1);break;
break之前是不是还应该加个delay?否则第二个状态一闪而过(微秒级的一闪而过),根本看不到。