DIY Projects
Published © CC BY

How to make Smoke Detector Alarm

Hello Friends, In this video How to make Smoke Detector Alarm

BeginnerShowcase (no instructions)1 hour39,335
How to make Smoke Detector Alarm

Things used in this project

Story

Read more

Schematics

Daigram

Code

Arduino code

C/C++
/*******
 
 All the resources for this project:
 BIHARI LIFEHACKER

*******/

int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smokeA0 = A5;
// Your threshold value
int sensorThres = 400;

void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(smokeA0, INPUT);
  Serial.begin(9600);
}

void loop() {
  int analogSensor = analogRead(smokeA0);

  Serial.print("Pin A0: ");
  Serial.println(analogSensor);
  // Checks if it has reached the threshold value
  if (analogSensor > sensorThres)
  {
    digitalWrite(redLed, HIGH);
    digitalWrite(greenLed, LOW);
    tone(buzzer, 1000, 200);
  }
  else
  {
    digitalWrite(redLed, LOW);
    digitalWrite(greenLed, HIGH);
    noTone(buzzer);
  }
  delay(100);
}

Credits

DIY Projects
11 projects • 21 followers
Student
Contact

Comments

Please log in or sign up to comment.