cashghx 发表于 2012-6-12 21:28
你把你板子原理图和整个程序都弄上来看看吧。
单这样看。。
我水平不够。看不出来。 ...
#include
#include
#define uint unsigned int
#define uchar unsigned char
***it dula=P2^6;
***it wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void display(uchar,uchar,uchar,uchar,uchar,uchar);
void delay(uint);
void main()
{
while(1)
{
display(6,5,4,3,2,1);
}
}
void display(uchar one,uchar two,uchar three,uchar four,uchar five,uchar six)
{
dula=1;
P0=table[one];
dula=0;
P0=0xff;
wela=1;
P0=0xfe;//位选
wela=0;
delay(1);
dula=1;
P0=table[two];
dula=0;
P0=0xff;
wela=1;
P0=0xfe;//位选同上
wela=0;
delay(1);
dula=1;
P0=table[three];
dula=0;
P0=0xff;
wela=1;
P0=0xfb;
wela=0;
delay(1);
dula=1;
P0=table[four];
dula=0;
P0=0xff;
wela=1;
P0=0xf7;
wela=0;
delay(1);
dula=1;
P0=table[five];
dula=0;
P0=0xff;
wela=1;
P0=0xef;
wela=0;
delay(1);
dula=1;
P0=table[six];
dula=0;
P0=0xff;
wela=1;
P0=0xdf;
wela=0;
delay(1);
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
|