This circuit is designed to interface an MQ-3 gas sensor with an Arduino UNO. The circuit includes a buzzer and an LED to provide visual and auditory alerts based on the sensor readings. The Arduino UNO reads both digital and analog signals from the MQ-3 sensor and controls the LED and buzzer accordingly.
Arduino UNO
Buzzer
Resistor
MQ-3 Breakout
LED: Two Pin (green)
/* MQ-3 sensor with Arduino.
created by the SriTu Tech team.
Read the code below and use it for any of your creations.
Home Page
*/
#define sensorDigital 2
#define LED 3
#define buzzer 4
#define sensorAnalog A1
void setup() {
pinMode(sensorDigital, INPUT);
pinMode(LED, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop() {
bool digital = digitalRead(sensorDigital);
int analog = analogRead(sensorAnalog);
Serial.print("Analog value : ");
Serial.print(analog);
Serial.print("\t");
Serial.print("Digital value :");
Serial.println(digital);
if (digital == 0) {
digitalWrite(LED, HIGH);
digitalWrite(buzzer, HIGH);
} else {
digitalWrite(LED, LOW);
digitalWrite(buzzer, LOW);
}
}
In the setup
function, the pins are initialized, and the serial communication is started. The loop
function reads the digital and analog values from the MQ-3 sensor and prints them to the serial monitor. If the digital value is low, the LED and buzzer are turned on; otherwise, they are turned off.