这个是ADC0809转换及显示程序,我想问AD_DATA[0]-AD_DATA[3]是十进制的吗?
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code LEDData[]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
sbit OE = P1^4;
sbit EOC = P1^5;
sbit ST = P1^6;
sbit CLK = P1^3;
uchar AD_DATA[5];
int i;
void DelayMS(uint ms)
{
uchar i;
while(ms--)
{
for(i=0;i<120;i++);
}
}
void Display_Result(uchar d)
{
for(i=0;i<100;i++)
{
P2 = 0xf7;
P0 = LEDData[d%10];
DelayMS(5);
P2 = 0xfb;
P0 = LEDData[d%100/10];
DelayMS(5);
P2 = 0xfd;
P0 = LEDData[d/100];
DelayMS(5);
}
}
void main()
{
TMOD = 0x02;
TH0 = 0x14;
TL0 = 0x00;
IE = 0x82;
TR0 = 1;
while(1)
{
P1 = 0x7c;
ST = 0;
ST = 1;
ST = 0;
while(EOC == 0);
OE = 1;
AD_DATA[0]=P3;
Display_Result(AD_DATA[0]);
OE = 0;
DelayMS(500);
P1 = 0x7b;
ST = 0;
ST = 1;
ST = 0;
while(EOC == 0);
OE = 1;
AD_DATA[1]=P3;
Display_Result(AD_DATA[1]);
OE = 0;
DelayMS(500);
P1 = 0x7a;
ST = 0;
ST = 1;
ST = 0;
while(EOC == 0);
OE = 1;
AD_DATA[2]=P3;
Display_Result(AD_DATA[2]);
OE = 0;
DelayMS(500);
P1 = 0x79;
ST = 0;
ST = 1;
ST = 0;
while(EOC == 0);
OE = 1;
AD_DATA[3]=P3;
Display_Result(AD_DATA[3]);
OE = 0;
DelayMS(500);
P1 = 0x78;
ST = 0;
ST = 1;
ST = 0;
while(EOC == 0);
OE = 1;
AD_DATA[4]=P3;
Display_Result(AD_DATA[4]);
OE = 0;
DelayMS(500);
}
}
void
timer0_INT() interrupt 1
{
CLK = !CLK;
}
亲,我邀请你加入,我qq1753493268。
一周热门 更多>