#include #include #define uint unsigned int #define uchar unsigned char void delay(uint z); uint temp; void main() { temp=0xfe; P0=temp; while(1) { delay(1000); temp=_crol_(temp,1); P0=temp; } } void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } 顺便要是的D1—>D2—>D3—>D4—>D5—>D6—>D7—>D8—>D7—>D6—>D5....这样的话用一个循环左移,一个循环右移就可以了 #include #include #define uint unsigned int #define uchar unsigned char void delay(uint z); uint temp,i; void main() { temp=0xfe; P0=temp; for(i=0;i<7;i++) { delay(1000); temp=_crol_(temp,1); P0=temp; } for(i=0;i<7;i++) { delay(1000); temp=_cror_(temp,1); P0=temp; } } void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); }
相关文章









