×
嵌入式 > 技术百科 > 详情

八通道adc0808数据采集

发布时间:2021-08-10 发布时间:
|

#include
#define uint unsigned int
#define uchar unsigned char
sbit EN=P0^4;
sbit EOC=P0^6;
sbit STA=P0^7;
sbit ADA=P0^0;
sbit ADB=P0^1;
sbit ADC=P0^2;
sbit ALE=P0^5;
uchar code tab[11]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xD8,0x80,0x90,0xff};
uchar code wela[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar data shu[8]={0,0,0,0,0,0,0,0};
uint ada=1222,adb=0;
uchar alley=0;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=4;y>0;y--);
}
void display()
{

uchar i,hp;

for(i=0;i<8;i++)
{
if(i==1)hp=0x80;else hp=0;
P3=wela[i];
P2=tab[shu[i]]+hp;
delay(10);
P3=0X00;
}
}
void disan()
{
ada=ada*100/51;
shu[4]=alley/1000;
shu[5]=alley%1000/100;
shu[6]=alley%100/10;
shu[7]=alley%10;
shu[0]=ada/1000;
shu[1]=ada%1000/100;
shu[2]=ada%100/10;
shu[3]=ada%10;
}
void adc()
{

ADA=alley&0x01;
ADB=alley&0x02;
ADC=alley&0x04;
STA=0;
delay(30);
STA=1;
delay(30);
STA=0;
while(!EOC)delay(1);
EN=1;
delay(2);
ada=P1;
EN=0;
}
void main()
{
uchar a=100;
while(1)
{
a=1000;
alley++;
if(alley>7)alley=0;
adc();
disan();
while(a--)
{

display();
}
}
}

 

 




『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
家庭网络:从带宽共享走向内容共享