#include <reg51.h> #define uchar unsigned char #define uint unsigned int delay(uint t); sbit P17=P1^7; //设置发光管的开关 main() {
P17=0; uchar k=0; //设置流水灯的方向标志位 uchar leds=0x01; P0=~leds; while(1) { delay(1000); if(k==0&&leds==0x80) { k=1; } else if(k==1&&leds==0x01) { k=0; } if(k==0) { leds=leds<<1; P0=~leds; } else { leds=leds>>1; P0=~leds; } }
} delay(uint t) { uint i,j; for(i=0;1<t;i++); for(j=0;j<223;j++); }
就这个简单流水灯,为什么编译老是说有K,leds没有被定义,编译无法通过,试着调整摆放P17的位置,却能编译成功,这到底为什么啊?谁能给个解释啊? |