请教了,初学比着葫芦画瓢写了个6LED灯逐个循环的C程序,就是不能按6位输出循环,请给看看这个取位应该怎么写,或者用什么方法解决这个问题。谢谢了!
#include <at89x52.h>
#include <Intrins.h>
unsigned char code tab[6]={0x01,0x02,0x04,0x08,0x10,0x20,};
unsigned char con;
unsigned int conss;
void main()
{
while(1)
{
if(++conss>55500)
{
conss=0;
con++;
con&=0x07; //现在是p2口8位循环,这个位怎么取才能使低6位LED循环?
P2=tab[con];
}
}
}
|