📄 ad.c
字号:
#include<reg51.h>
sfr ADC_CONTR =0xc5;
sfr ADC_DATA=0xc6;
sfr ADC_LOW2=0xbe;
sfr P1M0=0x91;
sfr P1M1=0x92;
sbit P1_1=P1^1;
sbit P2_7=P2^7;
sbit P2_2=P2^2;
sbit P2_6=P2^6;
int i=0,j=0,k=0,l=0,h=0,g=0;
int testbit;
int n;
int xbit,x;
int a[10]={0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09};
int b[6]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb};
delay()
{int n;
for(n=0;n<1200;n++)
;}
sendout(int c)
{
testbit=0x1;
n=0;
for (;n<=7;n++)
{if ((testbit&c)!=0)
P2_2=1;
else P2_2=0;
P2_6=1;
P2_6=0;
testbit=testbit<<1;
}
}
main()
{int N=0;
ADC_CONTR=ADC_CONTR | 0x80;
delay();
P1M0=0x01;
P1M1=0x01;
ADC_CONTR=ADC_CONTR | 0x08;
while((ADC_CONTR & 0x10)==0)
;
ADC_CONTR=ADC_CONTR & 0x00;
N=ADC_DATA;
ES=0;
TMOD=0x20;
SCON=0x50;
TH1=0xFB;
TL1=0xFB;
TR1=1;
SBUF=N;
while(TI==0)
;
TI=0;
l=N%10;
k=(N/10)%10;
j=(N/100)%10;
i=(N/1000)%10;
h=(N/10000)%10;
xbit=b[0];
sendout(xbit);
x=a[l];
sendout(x);
P2_7=0;
P2_7=1;
delay();
xbit=b[1];
sendout(xbit);
x=a[k];
sendout(x);
P2_7=0;
P2_7=1;
delay();
xbit=b[2];
sendout(xbit);
x=a[j];
sendout(x);
P2_7=0;
P2_7=1;
delay();
xbit=b[3];
sendout(xbit);
x=a[i];
sendout (x);
P2_7=0;
P2_7=1;
delay();
xbit=b[4];
sendout(xbit);
x=a[g];
sendout(x);
P2_7=0;
P2_7=1;
delay();
xbit=b[5];
sendout(xbit);
x=a[h];
sendout(x);
P2_7=0;
P2_7=1;
delay();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -