Lesson6-4
:
ADC0808
数字电压表,测量范围
0~5V
,仿真通过
#include
#defineucharunsignedchar
#defineuint
unsignedint
uchara[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,
0x6f};//
共阴极段码
ucharb[4];//
存放
4
位显示的数
sbitSTART=P2^4;
sbitOE=P2^6;
sbitEOC=P2^5;
voidmdelay(uintz)
{
uintx,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
voidshow(void)
{
uinti;
ucharc=0x01;
for(i=0;i<4;i++)
{
P1=(c<
P3=b[i];
if(i==2)//
显示小数点
P3=P3|0x80;
mdelay(1);
}
}
voidmain(void)
{
uintshuju=0;
while(1)
{
START=1;
START=0;//
下降沿启动转换信号
while(EOC==0)//
判断是否转换结束,
EOC=0
正在进行转换
{
OE=1;