|
#include "reg52.h" #define LED P0 void main() { unsigned int i=0; unsigned int j=0; while(1) { for(i=0;i<8;i++) { LED=(0x01<<i); //這句話的意思是讓1向左偏移i位,二進(jìn)制結(jié)果為:0000 0001,0000 0010,0000 0100,0000 1000,0001 0000,0010 0000,0100 0000,1000 0000 for(j=0;j<20000;j++); } for(i=0;i<8;i++) { LED=(0x08>>i);//這里的數(shù)值應(yīng)該是0x80吧? 等于是把上面的二進(jìn)制數(shù)慢慢的再退回來。 for(j=0;j<20000;j++); } } } |
|