|
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
#define LED P0
#define out P1
sbit start=P2^1;
sbit OE=P2^7;
sbit EOC=P2^3;
sbit clock=P2^0;
sbit add_a=P2^4;
sbit add_b=P2^5;
sbit add_c=P2^6;
void main(void)
{
uchar temp;
add_a=1;add_b=0;add_c=0; //选择ADC0809的通道0
while(1)
{
start=0;
start=1;
start=0; //启动转换
while(1)
{
clock=!clock;
if(EOC==1)
break;
}//等待转换结束
OE=1; //允许输出
temp=out; //暂存转换结果
OE=0; //关闭输出
LED=temp; //采样结果通过P0口输出到LED
}
}
附件中包含proteus仿真电路图
|
|