Alcohol Tester

From Wiki

Jump to: navigation, search

Kit List

Introduction:
Arduino advanced kit provided by ELECFREAKS is based on our starter kit to expand more and more popular modules owing the characteristics of plug and use without any requirement of soldering. We have well prepared six courses for learners to learn the usage of modules in an intersting environment which is better for stimulating your thinking mind. For example,Tetris games help us to study the usage of the LCD screen and Arduino program. Color picker used can help us to learn the color sensor as well as BLE Bluetooth communication and Android interface development ... Practical Course included LCD screen, sensor, MP3, BLE, WIFI, Android development, and image interaction (processing), make you open-minded!

Part2 Alcohol tester

Product introduction:
AD-part-2.gif Using Arduino to make an alcohol tester to remind your safe travel.
Alcohol 1.png Alcohol 2.png
Materials:
Easy to be made, because we provided all the hardware and software support
Only require:
*1xFreaduino Uno;
*1xMQ3 Sensor;
*1xTFT01-1.8;
*1xActive buzzer;

Parameter and IO definition:
1.5V power supply to mainboard
2.TFT的VCC-GND-CS-RESET-AO-SDA-SCK-LED successively connected with power supply(V)、ground(G)、D7、D6、D5、D4、D3、D2 of the mainboard.
3.MQ3 access to board analog A0 end, G (ground), V (power supply), S (IO port).
4.Active buzzer access to analog A1 end, G (ground), V (power supply), S (IO port).
Use instructions:
What I need to reminde you is that if you did not see the program, but prepared to use programming process directly, you need to initialize MQ3 after writing the program at least , because the sensor would require heating for 5M's normal execution.
After booting you can adjust potentiometer knob with a screwdriver. Until number 20 is displayed on the screen, it can be properly tested without correcting for many times.
Alcohol indicate.jpg
Working principles:
A.Tin oxide (SNO2) in MQ3 is more sensitive to alcohol, when it meets a variety of alcohol, it will quickly change the resistance value. When through series voltage divider circuit, it will be able to get different voltage values
B.Since the unit used in alcohol tester is not the same as the official, do not rely on it too much, only as a reference.
MQ3 reference data:
MQ3DATA1.jpg
MQ3DATA2.jpg

Arduino code

part2.zip


/*
 PART2 Alcohol Tester
 1. Use the UNO for programming; 
 2. Connect the MQ3 and the LCD, which can test and display the degree of alcohol;
 3. Connect an active buzzer to sound a warning if the degree of alcohol surpasses; 
 4. Note that you must use a screwdriver to adjust the MQ3 potentiometer for initial value calibration; 
 5. If it displays 20, then it is ok and does not require repeated calibration. 
 */
#include <UTFT.h>
#include <Timer.h>
#include <avr/pgmspace.h>
// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
 
Timer timer;  //get a timer
#define LCD_BL  2
UTFT mlcd(ITDB18SP,4,3,7,6,5);//get lcd controler(model,data,clk,cs,rst,control)
char distances[5]={'0','0','0','0','\0'};
char* distancetostring(int distance){
	distances[0]=distance%10000/1000+'0';
	distances[1]=distance%1000/100+'0';
	distances[2]=distance%100/10+'0';
	distances[3]=distance%10/1+'0';
return distances;
}
char time[9]={'0','0',':','0','0',':','0','0','\0'};
void times(){
if(time[7]=='9'){
	time[7]='0';
	if(time[6]=='5'){
		time[6]='0';
		if(time[4]=='9'){
			time[4]='0';
			if(time[3]=='5'){
				time[3]='0';
				if(time[0]!='2'){
					if(time[1]=='9'){
						time[1]='0';
						time[0]++;
					}
					else time[1]++;
				} else {
					if(time[1]=='3'){
					time[1]='0';time[0]='0';
					}else time[1]++;
				}
            }
			else time[3]++;
		}
		else time[4]++;
	}
	else time[6]++;
}
else time[7]++;
}
 
void start(){
 myGLCD.setFont(SevenSegNumFont);
 int len=analogRead(A0)-150;
 if(len<0)len=0;
 if(len<100){
 myGLCD.setColor(0,255,0);}
 else {
 myGLCD.setColor(255,0,0);
 }
 myGLCD.print(distancetostring(len),15,55);
 if(len>150){
	analogWrite(A1,200);
	delay(500);
	analogWrite(A1,0);
	}
 
	}
void printtime(){
	times();
	myGLCD.setFont(SmallFont);
	myGLCD.setColor(255,255,0);
    myGLCD.print(time,5,113);
}
 
void setup()
{
   pinMode(A0,0);  //MQ3 pin A0
   pinMode(A1,1);  //Active buzzer
   pinMode(LCD_BL,OUTPUT);
   digitalWrite(LCD_BL,HIGH);
  // Setup the LCD
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);
  myGLCD.setColor(0,0,255);//R G B
  myGLCD.print("init...",24,56);
  while(millis()<20000); //Heating MQ3 20S
    analogWrite(A1,200); //Detection alarm
    myGLCD.clrScr();
    myGLCD.print("Alcohol%",16,15);
    myGLCD.setFont(SmallFont);
	myGLCD.setColor(255,255,0);
    myGLCD.print(time,5,113);
    analogWrite(A1,0);
  timer.every(10,start);
  timer.every(1000,printtime);
  Serial.begin(9600);
  }
void loop()
{
timer.update();
}

Personal tools
Namespaces
Variants
Actions
Navigation
Support
Toolbox