《单片机控制二氧化碳传感器程序.doc》由会员分享,可在线阅读,更多相关《单片机控制二氧化碳传感器程序.doc(4页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精品文档,仅供学习与交流,如有侵权请联系网站删除#include /头文件#include #define uchar unsigned char /宏定义无符号字符型#define uint unsigned int /宏定义无符号整型typedef unsigned char BYTE;typedef bit BOOL; sbit ST=P30; /A/D启动转换信号sbit OE=P31; /数据输出允许信号sbit EOC=P32; /A/D转换结束信号sbit CLK=P33; /时钟脉冲 sbit LCD_RS = P20; sbit LCD_RW = P21;sbit LCD_E
2、N = P22;uchar m;uint AD0809,i,cdisplay,ppm;uint ppmdou;/定义数据类型void delay(int ms) / 延时子程序while(ms-) for(i = 0; i1072) ppm=400; else if(1049cdisplay)&(cdisplay=1072) ppmdou = (500-(cdisplay-1049)*(100/(1072-1049);ppm = (uint)ppmdou;else if(1036cdisplay)&(cdisplay=1049) ppmdou = (600-(cdisplay-1036)*(1
3、00/(1049-1036); /ppmdou = (500-(ppmd-1049)*(100/(1072-1049);ppm = (uint)ppmdou; else if(1023cdisplay)&(cdisplay=1036) ppmdou = (700-(cdisplay-1023)*(100/(1036-1023); ppm = (uint)ppmdou; else if(1016cdisplay)&(cdisplay=1023) ppmdou = (800-(cdisplay-1016)*(100/(1023-1016); ppm = (uint)ppmdou; else if(
4、1006cdisplay)&(cdisplay=1016) ppmdou = (900-(cdisplay-1006)*(100/(1016-1006); ppm = (uint)ppmdou; elseif(1000cdisplay)&(cdisplay=1006) ppmdou = (1000-(cdisplay-1000)*(100/(1016-1000); ppm = (uint)ppmdou; else if(966cdisplay)&(cdisplay=1000) ppmdou = (2000-(cdisplay-966)*(1000/(1000-966); ppm = (uint
5、)ppmdou; else if(947cdisplay)&(cdisplay=966) /2000-3000 ppmdou = (3000-(cdisplay-947)*(1000/(966-947); ppm = (uint)ppmdou; else if(924cdisplay)&(cdisplay=947)/3000-4000 ppmdou = (4000-(cdisplay-924)*(1000/(947-924); ppm = (uint)ppmdou; else if(907cdisplay)&(cdisplay=924)/4000-6000 ppmdou = (6000-(cd
6、isplay-907)*(2000/(924-907); ppm = (uint)ppmdou; else if(891cdisplay)&(cdisplay=907)/6000-8000 ppmdou = (8000-(cdisplay-891)*(2000/(907-891); ppm = (uint)ppmdou; else if(874cdisplay)&(cdisplay=891)/8000-10000 ppmdou = (10000-(cdisplay-874)*(2000/(891-874); ppm = (uint)ppmdou; else if(0cdisplay)&(cdi
7、splay=874)/8000-10000 ppm = 10000; lcd_pos(0x81); lcd_wdat(ppm/10000+0x30); lcd_pos(0x82); lcd_wdat(ppm%10000)/1000+0x30); lcd_pos(0x83); lcd_wdat(ppm%1000)/100+0x30); lcd_pos(0x84); lcd_wdat(ppm%100)/10+0x30); lcd_pos(0x85); lcd_wdat(ppm%10+0x30); lcd_pos(0x86); lcd_wdat(p); lcd_pos(0x87); lcd_wdat(p); lcd_pos(0x88); lcd_wdat(m); 【精品文档】第 4 页