请教路过的大神AD转换如何等效成电压值?
请教路过的大神AD转换如何等效成电压值?我用的是AD0804 我自己写的不知道你能不能看懂,液晶显示电压表//
#include <reg52.h>
sbit rs=P2^5;
sbit rw=P2^6;
sbit e =P2^7;
sbit cs=P1^0;
sbit clk=P1^1;
sbit addo=P1^2;
sbit addi=P1^3;
unsigned char xianshi[]="0123456789";
unsigned char i,ch,a,b,c;
/**************延时函数**************/
void delay (unsigned intx)
{
unsigned char f;
while(x--)
for(f=0;f<125;f++);
}
/**************液晶设置**************/
void write_order (unsigned char order)
{
e=0;
rs=0;
rw=0;
P0=order;
delay(1);
e=1;
delay(1);
e=0;
}
void write_data (unsigned char dat)
{
e =0;
rs=1;
rw=0;
P0=dat;
delay(1);
e=1;
delay(1);
e=0;
}
unsigned char adc0832()
{
ch=0;
cs=0;
clk =0;
addi=1;
clk =1;
clk =0;
addi=1;
clk =1;
clk =0;
addi=0;
clk =1;
clk =0;
for(i=0;i<8;i++)
{
clk =1;
clk =0;
ch=(ch|addo);
if(i!=7)
ch=ch<<1;
}
cs=1;
return ch;
}
void main ()
{
write_order (0x38);
write_order (0x0c);
while(1)
{
write_order (0x80+0x04);
write_data (xianshi);
write_data (xianshi);
write_data (xianshi);
delay(500);
}
}
谢谢我回去看看
页:
[1]