ArduinoHima
Published © Apache-2.0

Emergency Fire Alarm

Emergency Fire Alarm

BeginnerShowcase (no instructions)32
Emergency Fire Alarm

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Grove - Gas Sensor(MQ2)
Seeed Grove - Gas Sensor(MQ2)
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Fire Alarm

Code

Code

C/C++
float val;
#include <Wire.h>
#define A1 9
#define red 4
#define green 3

void setup() {
  pinMode(A0, INPUT);
  pinMode(A2,OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(green,OUTPUT);
  Serial.begin(9600);

}

void loop() {
  val = analogRead(A0);
  Serial.println(val);

  if(val > 150){
    digitalWrite(red,HIGH);
    digitalWrite(green,LOW);
    analogWrite(A1,500000);
    delay(200);
    analogWrite(A1,LOW);
    delay(100);
    analogWrite(A1,500000);
    delay(400);
    analogWrite(A1,LOW);
    delay(500);
  }

  else{
    delay(1000);
    digitalWrite(red,LOW);
    digitalWrite(green,HIGH);
    analogWrite(A1,LOW);
  }

  delay(100);
}

Credits

ArduinoHima

Posted by ArduinoHima

Comments

Add projectSign up / Login