unsigned char a, i;P2=a= 0x80;//假设P2上连接了8个LED、高电位时亮for(i=0; i<8; i++){ a=a<<1; P2=a; delay(100);}P2=0xff;//全亮delay(100);P2=0x0;//全灭delay(100);