2021-05-24

模数信号转换与显示实验

1.学习ADC0808的使用方法
2.学习动态显示模块程序的编写
ADC0808有8个模拟输入通道,本实验使用ADC0808的通道3,由通道3输入的模拟量转换为数字量后,显示在三位数码管上。

在这里插入图片描述

#include<reg51.h>
unsigned char code dispbitcode[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f,0x00};
unsigned char dispbuf[8]={10,10,10,10,10,0,0,0};
unsigned char dispcount;
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
unsigned char channel=0xbc;//IN3
unsigned char getdata;
void main(void)
{
  TMOD=0x01;
  TH0=(65536-4000)/256;
  TL0=(65536-4000)%256;
  TR0=1;
  ET0=1;
  EA=1;
P3=channel;
while(1)
{
  ST=0;
  ST=1;
  ST=0;
  while(EOC==0);
  OE=1;
  getdata=P0;
  OE=0;
  dispbuf[2]=getdata/100;
  getdata=getdata%10;
  dispbuf[1]=getdata/10;
  dispbuf[0]=getdata%10;
}
}
void t0(void) interrupt 1 using 0
{
  TH0=(65536-4000)/256;
  TL0=(65536-4000)%256;
  P1=dispcode[dispbuf[dispcount]];
  P2=dispbitcode[dispcount];
  dispcount++;
  if(dispcount==8)
  {
    dispcount=0;
} 
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值