Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elktros/46d787d343ad11d5aaff3ee52d3d659b to your computer and use it in GitHub Desktop.
Save elktros/46d787d343ad11d5aaff3ee52d3d659b to your computer and use it in GitHub Desktop.
Code for Arduino based Door Monitoring System using Reed Switch.
#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