← All Projects

Alcohol Detector

36 viewsApril 2, 2026
mq sensoralcohol detector

Components & Supplies

×1Arduino Uno R3
×1Breadboard
×1Active Buzzer
×1Green LED (5mm)
×1Yellow LED (5mm)
×1MQ-6 Ethanol Sensor
×10Jumper Wires (M-M)
×10Jumper Wires (M-F)
×19V Battery + Snap Connector
×1LM2596 Buck Converter

Circuit Connections

ComponentPinPinComponent
Arduino3+VEBuzzer
Arduino4+VELED 1
Arduino5+VELED 2
Arduino13D0MQ Sensor
ArduinoGND-VELED 1
ArduinoGND-VELED 1
ArduinoGNDGNDMQ SENSOR
Arduino5VVCCMQ SENSOR
ArduinoGND-VEBuzzer
arduinocode.ino
// Pin Definitions
const int sensorPin = 13;   // MQ sensor data input
const int defaultLed = 3;   // Standard LED (Always on initially)
const int buzzerPin = 2;    // Buzzer for alert
const int alarmLed = 4;     // Yellow LED for alert

void setup() {
  // Initialize Pin Modes
  pinMode(sensorPin, INPUT);
  pinMode(defaultLed, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(alarmLed, OUTPUT);

  // Initial State: Default LED on, others off
  digitalWrite(defaultLed, HIGH);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(alarmLed, LOW);
  
  Serial.begin(9600); // For monitoring status
}

void loop() {
  // Read the sensor state (HIGH if alcohol detected, LOW otherwise)
  int sensorStatus = digitalRead(sensorPin);

  if (sensorStatus == HIGH) {
    // Alcohol Detected!
    digitalWrite(defaultLed, LOW);  // Turn off default LED
    digitalWrite(buzzerPin, HIGH);  // Activate Buzzer
    digitalWrite(alarmLed, HIGH);   // Turn on Yellow LED
    
    Serial.println("Warning: Alcohol Detected!");
  } 
  else {
    // No Alcohol Detected
    digitalWrite(defaultLed, HIGH); // Keep default LED on
    digitalWrite(buzzerPin, LOW);   // Silence Buzzer
    digitalWrite(alarmLed, LOW);    // Turn off Yellow LED
    
    Serial.println("Status: Clear");
  }

  delay(100); // Small delay for stability
}