#include
#define uchar unsigned char
#define uint unsigned int
uchar adval;
uchar tt[]={ 0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x40
};
sbit CS=P3^4;
sbit CLK=P1^0;
sbit DIO=P1^1;
uchar A_D(bit CH)
{
uchar i;
CS=0;
CLK=0;
CLK=1;
DIO=1;
if(CH==0)
{
CLK=0;
CLK=1;
DIO=1;
CLK=0;
CLK=1;
DIO=0;
}
else
{
CLK=0;
CLK=1;
DIO=1;
CLK=0;
CLK=1;
DIO=1;
}
CLK=1;
CLK=0;
for(i=0;i<8;i++)
{
CLK=1;
CLK=0;
if(DIO)
adval=(adval>>1)|0x80;
else
adval=(adval>>1)|0x00;
}
CS=1;
return(adval);
}
void delay1()
{
int k;
for(k=0;k<400;k++);
}
void display(int k)
{
P2=0xfe;
P0=tt[k/1000];
delay1();
P2=0xfd;
P0=tt[k%1000/100];
delay1();
P3=0xfb;
P0=tt[k%100/10];
delay1();
P2=0xf7;
P0=tt[k%10];
delay1();
P2=0xff;
}
void main()
{
P2=0xff;
P0=0xff;
while(1)
{
A_D(0x01);
display(adval);
}
}
阅读(534) | 评论(0) | 转发(0) |