Created
June 18, 2020 15:25
-
-
Save AZ979/8e344619862e4a76c3c2770344776add to your computer and use it in GitHub Desktop.
Arduino Gas Detecting Alarm System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(5,6,8,9,10,11); | |
int redled = 2; | |
int greenled = 3; | |
int buzzer = 4; | |
int sensor = A0; | |
int sensorThresh = 400; | |
void setup() | |
{ | |
pinMode(redled, OUTPUT); | |
pinMode(greenled,OUTPUT); | |
pinMode(buzzer,OUTPUT); | |
pinMode(sensor,INPUT); | |
Serial.begin(9600); | |
lcd.begin(16,2); | |
} | |
void loop() | |
{ | |
int analogValue = analogRead(sensor); | |
Serial.print(analogValue); | |
if(analogValue>sensorThresh) | |
{ | |
digitalWrite(redled,HIGH); | |
digitalWrite(greenled,LOW); | |
tone(buzzer,1000,10000); | |
lcd.clear(); | |
lcd.setCursor(0,1); | |
lcd.print("ALERT"); | |
delay(700); | |
lcd.clear(); | |
lcd.setCursor(0,1); | |
lcd.print("EVACUATE"); | |
delay(700); | |
} | |
else | |
{ | |
digitalWrite(greenled,HIGH); | |
digitalWrite(redled,LOW); | |
noTone(buzzer); | |
lcd.clear(); | |
lcd.setCursor(0,0); | |
lcd.print("SAFE"); | |
delay(700); | |
lcd.clear(); | |
lcd.setCursor(0,1); | |
lcd.print("ALL CLEAR"); | |
delay(700); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment