Introduction
This experiment demonstrates how to use the MQ-3 alcohol sensor with Arduino to detect alcohol concentration in the air.
Components Needed
- MQ-3 Alcohol Sensor
- Arduino (e.g., Uno, Nano)
- LED
- 220-ohm Resistor
- Jumper wires
Circuit Setup
- Connect the MQ-3 sensor to the analog input pin A0 on the Arduino.
- Connect the LED to a digital output pin on the Arduino using a 220-ohm resistor in series.
The LED will light up when the alcohol concentration exceeds a certain threshold.
Code for Alcohol Sensor MQ-3
Upload the following code to your Arduino to detect alcohol concentration:
const int alcoholPin = A0;
const int ledPin = 13;
int sensorValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(alcoholPin);
Serial.println(sensorValue);
if (sensorValue > 400) { // Threshold value
digitalWrite(ledPin, HIGH); // Turn on LED if alcohol concentration is high
} else {
digitalWrite(ledPin, LOW); // Turn off LED if alcohol concentration is low
}
delay(100);
}
Explanation
The MQ-3 alcohol sensor detects alcohol in the air and outputs an analog signal, which is read by the Arduino. If the sensor value exceeds the threshold, the LED turns on.
Troubleshooting
- If the sensor is unresponsive, check the wiring and ensure it is properly powered.
- If the LED doesn't turn on, try adjusting the threshold in the code according to the sensor readings.