tibaldiandre_teo
Published

No more explosions

We thought that in every house we could have a gas leak and consequently a fire so we have designed a project that delete this problem.

BeginnerFull instructions provided128
No more explosions

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Grove - Gas Sensor(MQ2)
Seeed Grove - Gas Sensor(MQ2)
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Buzzer
Buzzer
×1
Resistor 221 ohm
Resistor 221 ohm
×1

Story

Read more

Schematics

ELECTRICIAN OPERATION SCHEME FRITZING

Code

CODE

Arduino
#include <Servo.h>

Servo myservo;
int smoke = A0;                              //smoke sensor to arduino pin A0
int buzzer = 9;                              //buzzer to arduino pin 9
int sensorThreshold = 65;                    //minimun sensor activation threshold
int motorPin = 4;                            //motor to arduino pin 4

void setup () {
  pinMode(buzzer, OUTPUT);                   //buzzer data is set as OUTPUT 
  pinMode(smoke, INPUT);                     //sensor data is set as INPUT 
  Serial.begin (9600);
  myservo.attach(11);                        //servo to arduino pin 13
  pinMode(motorPin, OUTPUT);                 //motor is set as OUTPUT
}
void loop() {

  int analogSensor = analogRead(smoke);      //the analogue number obtained is the value detected by the sensor 
  if (analogSensor >= sensorThreshold)       //the value detected by the sensor must be higher of the threshold 
  {
    myservo.write(90);                       //servo moves to 90°
    digitalWrite(motorPin, HIGH );           //motor turns on 
    tone(buzzer, 250, 2500);                 //buzzer sounds at a frequency of 250 Hz for 2,5 seconds  
    delay(8000);                             //the servo remains stationary for 8 seconds
    digitalWrite(motorPin, LOW );            //motor turns off
  }
  else
  {
    myservo.write(0);                        //the servo remains stationary at 0°
    noTone(buzzer);                          //buzzer doesn't emit sounds
  }
  Serial.println(analogSensor);

  delay(50);
}

Credits

tibaldi

tibaldi

0 projects • 0 followers
andre_teo

andre_teo

0 projects • 0 followers

Comments

Add projectSign up / Login