ข้ามไปที่เนื้อหาหลัก

Mini Project


Alcohol Detector

อุปกรณ์

- MQ-3 alcohol sensor
- Arduino uno
- 10pcs 5V active buzzer
- Microtivity IM206 6x6x6mm tact switch
- 12C LCD screen
- 10 kOhm resistor
- Breadboard
- 10 X male/male jumper wires
- 10 X male/female jumper wires
Diagram

Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
const int buttonPin = 2;
const int buzzerPin = 7;
const int AOUTpin=0;//the AOUT pin of the alcohol sensor goes into analog pin A0 of the arduino
const int DOUTpin=8;//the DOUT pin of the alcohol sensor goes into digital pin D8 of the arduino
const int ledPin=13;//the anode of the LED connects to digital pin D13 of the arduino
int ledpin1 = 3;
int ledpin2 = 4;
int ledpin3 = 5;
int limit;
int value;
int buttonState = 0; 
void setup() {
Serial.begin(9600);
 lcd.init(); 
 lcd.backlight();
pinMode(buttonPin, INPUT); 
pinMode(buzzerPin,OUTPUT);
pinMode(DOUTpin, INPUT);//sets the pin as an input to the arduino
pinMode(ledpin1, OUTPUT);
pinMode(ledpin2, OUTPUT);
pinMode(ledpin3, OUTPUT);//sets the pin as an output of the arduino
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {  
value= analogRead(AOUTpin);//reads the analaog value from the alcohol sensor's AOUT pin
  Serial.println(value);
 if(value<200)
  {
      Serial.println("You are fine.");
      lcd.print("Result ");
      lcd.print(value);
      lcd.setCursor(0,1);
      lcd.print("You are fine.");
      digitalWrite(buzzerPin,LOW);
      digitalWrite(ledpin1, HIGH);
      delay(1000);
      digitalWrite(buzzerPin,HIGH);
      digitalWrite(ledpin1, LOW);
  }
  if (value>=200 && value<280)
  {
      Serial.println("Alcohol detected");
      lcd.print("Result ");
      lcd.print(value);
      lcd.setCursor(0,1);
      lcd.print("Alcohol Detected");
      digitalWrite(buzzerPin,LOW);
      digitalWrite(ledpin2, HIGH);
      delay(750);
      digitalWrite(buzzerPin,HIGH);
      digitalWrite(ledpin2, LOW);
  }
  if (value>=280 && value<350)
  {
      Serial.println("Just A Little.");
      lcd.print("Result ");
      lcd.print(value);
      lcd.setCursor(0,1);
      lcd.print("Just A Little.");
      digitalWrite(buzzerPin,LOW);
      digitalWrite(ledpin2, HIGH);
      delay(500);
      digitalWrite(buzzerPin,HIGH);
      digitalWrite(ledpin2, LOW);
  }
  if (value>=350 && value <450)
  {
      Serial.println("Serious Booze here! ");
      lcd.print("Result ");
      lcd.print(value);
      lcd.setCursor(0,1);
      lcd.print("No More Drink!");
      digitalWrite(buzzerPin,LOW);
      digitalWrite(ledpin3, HIGH);
      delay(250);
      digitalWrite(buzzerPin,HIGH);
      digitalWrite(ledpin3, LOW);
  }
  if(value>450)
  {
     Serial.println("You are drunk!");
     lcd.print("Result ");
     lcd.print(value);
     lcd.setCursor(0,1);
     lcd.print("R.I.P");
     digitalWrite(buzzerPin,LOW);
     digitalWrite(ledpin3, HIGH);
  }
  delay (500);
  lcd.clear();
}
else{
  lcd.setCursor(0,0);
  lcd.print("Alcohor Meter");
  lcd.setCursor(0,1);
  lcd.print("Press Button...");
  digitalWrite(buzzerPin,HIGH);
  delay(500);
  lcd.clear();
  }
}

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

ส่งงานครั้งที่ 17

Air Pollution Monitoring อุปกรณ์ MQ135 Gas sensor Arduino Uno Wi-Fi module ESP8266 16X2 LCD Breadboard 10K potentiometer 1K ohm resistors 220 ohm resistor Buzzer Diagram Code #include "MQ135.h" #include <SoftwareSerial.h> #define DEBUG true SoftwareSerial esp8266(9,10); // กำหนดขา 9 ของ Arduino เป็น RX pin และ ขา 10 ของ Arduino เป็น the TX pin const int sensorPin= 0; int air_quality; #include <LiquidCrystal.h> LiquidCrystal lcd(12,11, 5, 4, 3, 2); void setup() { pinMode(8, OUTPUT); lcd.begin(16,2); lcd.setCursor (0,0); lcd.print ("circuitdigest "); lcd.setCursor (0,1); lcd.print ("Sensor Warming "); delay(1000); Serial.begin(115200); esp8266.begin(115200);   sendData("AT+RST\r\n",2000,DEBUG); // reset module   sendData("AT+CWMODE=2\r\n",1000,DEBUG); // กำหนดค่า  access point   sendData("AT+CIFSR\r\n",1000,DEBUG); // รับ ip address   sendData("AT+CIPMUair_quali

ส่งงานครั้งที่ 16

Smoke Detector Using MQ2 อุปกรณ์ Arduino UNO Smoke Detector Arduino Shield (Self Designed) Power Supply Smoke Sensor (MQ2) Resistors (10K and 1K) Buzzer 16x2 LCD 10k POT LED LM358 Burg strips Diagram Code #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #define buzzer 9 #define sensor A0   #define load_Res 10   #define air_factor 9.83                                                   float SmokeCurve[3] ={2.3,0.53,-0.44};    // (x, y, slope) x,y พิกัดของจุดหนึ่งและความลาดชันระหว่างสองจุด                                                                                       float Res=0;                 void setup() {   lcd.begin(16,2);   lcd.print("Calibrating.....");                 Res = SensorCalibration();                                                                                           lcd.print("Calibration done.");   lcd.setCursor(0,1);   lcd.print("Res=");   lcd.print(

ส่งงานครั้งที่ 18

12 V Battery Charger อุปกรณ์ Transformer 12V 1Amp IC LM317 (2) Diode Bridge W005 Connector Terminal Block (2) Capacitor 1000uF, 1uF Capacitor 0.1uF (5) Variable resistor 100R Resistor 1k (5) Resistor 10k Diode- Nn007  (3) LM358 – Opamp 0.05R - Shunt Resistor/wire LCD-16*2 (optional) Arduino Nano (optional) Diagram Code #include <LiquidCrystal.h>// ประกาศเมื่อใช้LCD LiquidCrystal lcd(11, 12, 10, 9, 8, 7); float voltage,current;  void setup() {   Serial.begin(9600);   //ตั้งค่าLCD   lcd.begin(16, 2);   // Print a message to the LCD.   lcd.setCursor(0, 0);   lcd.print("12V Charger");   lcd.setCursor(0, 1);   lcd.print("-Circuit Digest");   delay(2000);   lcd.clear();   lcd.setCursor(0, 0);   lcd.print("Voltage = ");   lcd.setCursor(0, 1);   lcd.print("Current = "); } void loop() {   voltage = (analogRead(A0)) * 0.0140625;   current = (analogRead(A1)) * 0.35;           lcd.setCursor(1