#include unsigned int x;//shift to the left water lampvoid main(){ x=50000; P1=0x01; while(1) { while(x--); //delay time P1=P1<<1; //左移 if(P1==0x00) P1=0x01; //回到起始位置 }}
3. 流水灯(右移法)
#include unsigned int x;//shift to the right water lampvoid main(){ x=50000; P1=0x80; while(1) { while(x--); P1=P1>>1; if(P1==0x00) P1=0x80; }}
#include unsigned int x;//shift to the left water lampvoid main(){ x=50000; P1=0x01; while(1) { while(x--); //delay time P1=P1<<1; //左移 if(P1==0x00) P1=0x01; //回到起始位置 }}
3. 流水灯(右移法)
#include unsigned int x;//shift to the right water lampvoid main(){ x=50000; P1=0x80; while(1) { while(x--); P1=P1>>1; if(P1==0x00) P1=0x80; }}