附录四:电压表源程序: #include
#define uchar unsigned char #define uint unsigned int
#include%uchar code table[]= {
0xc0,0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90,
}; //共阳数码管段码表 没有小数点 0~9
- 21 -
uchar code table1[]= {0x40,0x79,0x24,0x30,0x19,
0x12,0x02,0x78,0x00,0x10};//带小数点的编码 0~9
uchar dat=0;//AD值 uint c,d;
uint DY_dat=0; //烟雾浓度数据 uchar ad_dat1=0; //读取滤波后的AD值 uchar count=0;//定时器计数 uchar CH=0;//通道变量
uint num,ge,xiao1,xiao2,shi,shi1,ge1,xiao3,xiao4,dy;
/**********************************************************/
/********************************************************* 延时函数
**********************************************************/ void delay(uint x) { uint a,b;
- 22 -
for(a=x;a>0;a--) for(b=110;b>0;b--); }
void Read_ad() {
static uint AD_DAT=0; float ad_buf=0; static uchar i=0; if(i<5) // 滤 { i++;
AD_DAT+=A_D(); // 波 }
else // 算 {
i=0; // 法 ad_dat1=(uchar)(AD_DAT/5);
- 23 -
ad_buf=(float)(ad_dat1/0.51); DY_dat=(uint)(ad_buf); AD_DAT=0; } }
/******************************************************** 显示函数
********************************************************/
void display() {
shi1=DY_dat/1000; ge1=DY_dat00/100; xiao2=DY_dat0/10; xiao3=DY_dat;
- 24 -
P2=0xfd; P0=table1[ge1]; delay(3);
P2=0xfb;
P0=table[xiao2]; delay(3);
P2=0xf7;
P0=table[xiao3]; delay(3);
P2=0xff; }
/********************************************************* 主函数
**********************************************************/
- 25 -
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库ADC0832数字电压表(5)在线全文阅读。
相关推荐: