Smoke Sensor with Arduino buzzer
Smoke Sensor with Arduino buzzer
Circuit Diagram-
Pins Connection
1. Arduino Digital pin 0 is connected with the (+ve) pin of Buzzer 2. Arduino Digital pin 1 is connected
with the (+ve) pin of LED1 (green) 3. Arduino Digital pin 2 is connected with the (+ve) pin of LED2(red)
4. Arduino Analog pin A0 is connected with A0 Pin of MQ2 Gas sensor 5. Arduino 5v Power pin is
connected with VCC pin of Gas sensor 6. Arduino GND Power pin is connected with GND pin of Gas
sensor 7. Arduino GND Power pin is connected with (-ve) pins of LED’s with resistance 8.Arduino
GND Power pin is connected with GND pins of a Buzzer with resistance
Arduino Code
//stored pins in variables
#define gasSensor A0
#define buzzer 0
#define ledGreen 1
#define ledRed 2
#define HIGH 600
void setup() {
pinMode(gasSensor, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(ledRed, OUTPUT);
}
void loop() {
//Read data from the sensor
int gas_value = analogRead(gasSensor);
//check data from sensor if there is smoke, if will execute otherwise else will execute
if(gas_value > HIGH)
{
tone(buzzer,1000,500);
digitalWrite(ledRed, HIGH);
digitalWrite(ledGreen,LOW);
}
else
{
noTone(buzzer);
digitalWrite(ledGreen,HIGH);
digitalWrite(ledRed, LOW);
}
delay(200);
Result- Find the result by smoke sensor detect signal and buzzer start beeping