-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFire_Alarm_System.ino
More file actions
62 lines (47 loc) · 1.09 KB
/
Copy pathFire_Alarm_System.ino
File metadata and controls
62 lines (47 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 16, 2);
int sensorPin = A0;
int buzzer = 8;
int led = 9;
int lowThreshold = 300;
int mediumThreshold = 450;
void setup() {
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Fire System");
Serial.begin(9600);
}
void loop() {
int value = analogRead(sensorPin);
Serial.println(value);
if (value < lowThreshold) {
// LOW
lcd.setCursor(0, 0);
lcd.print("Status: SAFE ");
lcd.setCursor(0, 1);
lcd.print("Smoke: LOW ");
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
} else if (value < mediumThreshold) {
// MEDIUM
lcd.setCursor(0, 0);
lcd.print("Warning Level ");
lcd.setCursor(0, 1);
lcd.print("Smoke: MEDIUM ");
digitalWrite(buzzer, LOW);
digitalWrite(led, HIGH);
} else {
// HIGH
lcd.setCursor(0, 0);
lcd.print("FIRE ALERT!!! ");
lcd.setCursor(0, 1);
lcd.print("Smoke: HIGH ");
digitalWrite(buzzer, HIGH);
digitalWrite(led, HIGH);
}
delay(300);
}