Created
June 6, 2018 11:15
-
-
Save elktros/46d787d343ad11d5aaff3ee52d3d659b to your computer and use it in GitHub Desktop.
Code for Arduino based Door Monitoring System using Reed Switch.
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> | |
const int reedPin = 8; | |
const int ledPin = 13; | |
const int RS = 7, EN = 6, D4 = 5, D5 = 4, D6 = 3, D7 = 2; | |
bool switchState = HIGH; | |
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); | |
void setup() | |
{ | |
lcd.begin(16,2); | |
//Serial.begin(9600); | |
pinMode(reedPin, INPUT); | |
pinMode(ledPin, OUTPUT); | |
digitalWrite(ledPin, LOW); | |
lcd.print("Electronics Hub"); | |
lcd.setCursor(0,1); | |
lcd.print(" Presents "); | |
delay(3000); | |
lcd.setCursor(0,0); | |
lcd.print("Door Monitoring "); | |
lcd.setCursor(0,1); | |
lcd.print(" System "); | |
delay(3000); | |
} | |
void loop() | |
{ | |
switchState = digitalRead(reedPin); | |
if(switchState == LOW) | |
{ | |
digitalWrite(ledPin, LOW); | |
//lcd.clear(); | |
lcd.setCursor(0,0); | |
lcd.print(" Door is closed "); | |
lcd.setCursor(0,1); | |
lcd.print(" No Worries "); | |
} | |
else | |
{ | |
digitalWrite(ledPin, HIGH); | |
lcd.setCursor(0,0); | |
lcd.print(" Door is Open "); | |
lcd.setCursor(0,1); | |
lcd.print(" BREACH BREACH" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment