使用说明:
上电以后,需要预热一段时间,此时lcd显示Loading... (预热过程为电压先上升后下降的改成,通过检测电压来检测是否预热完成) , 预热完成后显示酒精浓度,按下按下按键key1即可进入报警设置模式,按下key2加,key3减, 再次按下key1退出报警设置模式(必须为报警设置模式key2和key3才起作用)
原理图:
PCB:
程序运行图:
部分程序:
#include "stc89x_90x.h"
#include "LCD1602.h"
#include "ADC0832.h"
#include "intrins.h"
sbit k1=P1^4;
sbit k2=P1^5;
sbit k3=P1^6;
sbit beep=P3^5;
sbit beep2=P3^2;
sbit beep3=P3^3;
sbit beep4=P3^4;
sbit led=P3^6;
unsigned char temp1[]={"Potency: **%"}; //ÏÔʾ¾Æ¾«Å¨¶È
unsigned char temp2[]={"early:**% "}; //ÏÔʾŨ¶ÈÔ¤¾¯Öµ
unsigned char temp3[]={"Loading... "};
unsigned char key,a;
unsigned char dat=50; //¾Æ¾«Å¨¶ÈÔ¤¾¯³õʼλ
long int m;
void Delay1000ms() //@11.0592MHz
{
unsigned char i, j, k;
_nop_();
i = 8;
j = 1;
k = 243;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
/********
void concentration()
¾Æ¾«Å¨¶È¼ÆËã
*********/
void concentration()
{
unsigned char count; //¶¨Òå8λµÄcout
long int a; //¶¨Ò峤ÕûÐͱäÁ¿
count=ADC_acquisition(); //½«ADC0832¶Á³öµÄÖµ¸³¸øcount
a=count*50;
count=(float)(a/256);
if(count<13)
count=(float)(13); //µ±µçѹֵСÓÚ1.4Vʱ£¬½«µçѹֵ¹Ì¶¨ÔÚ1.4V
else
count=(float)(count-13)*3.5; //¼ÆËã¾Æ¾«Å¨¶ÈΪһ¸ö¸¡µãÐͱäÁ¿
/* ÕâÒ»¾äûÓÐÓÃÉÏÒ»¾äcountΪu8ÀàÐÍÒѾÍê³ÉÁËÀàÐÍת»»
count=(char)count;
*/
if(count>=100) //µ±Å¨¶È´óÓÚ100%ʱ£¬½«Å¨¶È¹Ì¶¨ÔÚ100%
{
count=100;
temp1[8]=count/100+'0';
}
else temp1[8]=' ';
temp1[9]=count%100/10+'0'; //½«Å¨¶ÈÖµ¸³¸øÊý×é
temp1[10]=count%100%10+'0';
m=count;
}
/************
void loading()
³õʼ¼ÓÔØ(Ô¤ÈÈ)º¯Êý
*************/
void loading()
{
unsigned char s=10;
while(s--)
{
WriteInstruction(0x80);
a=0;
while(temp3[a]!='
相关文章