Instructions for use:
After powering on, it needs to be preheated for a period of time. At this time, the LCD displays Loading... (the preheating process is changed to the voltage rising first and then falling, and the voltage is detected to detect whether the preheating is completed). After the preheating is completed, the alcohol concentration is displayed. , press key1 to enter the alarm setting mode, press key2 to increase, key3 to decrease, press key1 again to exit the alarm setting mode (key2 and key3 must be in the alarm setting mode to work)
Schematic:
PCB:
Program operation chart:
Part of the program:
#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]!='')
{
WriteData(temp3[a]);
a++;
}
}
Delay1000ms();Delay1000ms();
Delay1000ms ();Delay1000ms();
while(1)
{
concentration();
if(m==0)
{
temp3[7]=' ';
temp3[8]='O';
temp3[9]='K';
}
WriteInstruction(0x80);
a=0;
while(temp3[a]!='')
{
WriteData(temp3[a]);
a++;
}
if(m==0)
{
Delay1000ms();
break;
}
}
}
/********
void independent()
Ô¤¾¯Ñ¡ Ôñ룬k2ΪÔö¼Ó£¬k3Ϊ¼õÉÙ
*********/
void independent()
{
if(k2==0)
{
delay(1000);
if(k2==0)
{
while(k2==0 );
dat++;
if(dat==100)dat=99;
}
}
if(k3==0)
{
delay(1000);
if(k3==0)
{
while(k3==0);
dat--;
if(dat==0)dat=1;
}
}
temp2[6]=dat/10+'0';
temp2[7]=dat%10+'0';
}
/****************
void first_line()
ÏÔʾµÚÒ»ÐУ¬¼´Îª¾Æ¾«Å¨¶È
***************/
void first_line ()
{
WriteInstruction(0x80);
a=0;
while(temp1[a]!='')
{
WriteData(temp1[a]);
a++;
}
delay(1000);
}
/**************
void second_line()
ÏÔʾµÚ¶ÐУ¬¼´Îª¾Æ¾«Å¨¶ÈÔ¤¾¯Öµ
**************/
void second_line()
{
independent();
temp2[6]=dat/10+'0';
temp2[7]=dat%10+'0';
WriteInstruction(0x80+0x40);
a=0;
while(temp2[ a]!='')
{
WriteData(temp2[a]);
a++;
}
delay(1000);
}
/********
void main()
Ö÷º¯Êý
********/
void main()
{
unsigned char n=0;
key=0;
Init();
loading();
Init ();
while(1)
{
concentration(); //¾Æ¾«Å¨¶È¼ì²âλ
first_line(); //ÏÔʾµÚÒ»Ðоƾ«Å¨¶È
if(k1==0)
{
delay(1000);
if( k1==0)
{
while(k1==0);
if(key==0)key=1;
else key=0;
}
}
if(key==1)
{
independent();
second_line();
n= 1;
}
if(key==0)
{
if(n==1)
{
WriteInstruction(0x01);
}
n=0;
}
if(dat<=m)
{
led=0;
Previous article:Bluetooth password lock based on 51 microcontroller
Next article:Simulation design of dancing robot stepper machine based on 51 microcontroller
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- I have some questions about project handover (software) at work. I hope experienced seniors can give me some guidance.
- Learn about RF MEMS switches in one article
- CC2541 Bluetooth Learning-Clock Setting
- Dismantle ABC and CCB U-Shield
- How to view MSP430 technical data
- How to view the status of GPIO ports during CCS5.5 debugging
- ISO7637
- About WiFi module
- Simple RISC processor design
- CC2541 (Master UART) - CC2541 (Slave UART) Serial Port Transparent Transmission Experiment