|
发表于 2011-4-28 06:07:40
|
显示全部楼层
P2=0X01 ;// 最右端:秒个位亮
P2=0X02;//秒十位亮,个位灭
P2=0X04,;//分个位亮,秒十位灭,如果要点8个管,就要写8个语句,太累了!
也可以这样
unsigned char a=0x01;//
P2=a; //P2点亮秒个位
a=a<<1;
P2=a; //P2点亮秒十位,以后我们会通过循环操作就不要写8个句子了。
i will give you a simpler solution
#define OUT_PORT P2 //output on p2
OUT_PORT <= 1; //left shift OUT_PORT by 1
the advantage here is that if you were to change the output from P2 to P3, all you need is to redefine OUT_PORT to be P3 and the code will work. |
|