Door Monitoring

Introduction: Door Monitoring

So this is my first project ,baby steps here, just wanted to monitor door contacts and later bring the information into an app to show on my phone.


Parts required are minimal;
1 x Arduino board, mini,uno nano 1 x 100 k resistor 2 x 200 ohm resistors 1 x push button (used for testing purposes only.

Step 1: Programming Arduino + Code

Assuming you have Arduino IDE software

under File - new

under Tools - select your board

int redPin = 8; //Declares Red led

int greenPin = 9; //Declares Green led

int doorState; //Checks state of door

int door = 12; //Arduino pin connected

int contactOld; // Checks the contact state at start

int contactNew = 1; //Checks contact state change

int dt = 50; //Time delay

void setup() {

Serial.begin(9600); //Start serial monitor

pinMode(door, INPUT); //Declares door as an input

pinMode(redPin, OUTPUT); // Declares Red led as an output

pinMode(greenPin, OUTPUT); //Declares Green led as output


void loop() {

contactNew = digitalRead(door); //Checks the state of the door contact


digitalWrite(redPin,LOW); //Turns off Red led

doorState = 1; // Check if contact is registering 1

Serial.println("Door is Closed"); } //Prints Door is Closed

else {

digitalWrite(redPin, HIGH); //Turns on Red led

digitalWrite(greenPin,LOW); //Turns Green led off

doorState = 0; //Check if contact =0

Serial.println("Door is Open"); //Print Door is closed



contactOld = contactNew; //checks last state of door contact

delay(dt); //sets delay


Step 2: A Little Explanation Here

So basically here what I have made is a program that will monitor any opening in your house like door, window or garage door . The led's in this project are just for indicating that there was an output either open or closed, not required unless you want to show it on a board. I also used a push button on my circuit to simulate door contacts changing state, you could also replace the led with a piezo buzzer. You could also output this to a LCD display and an annunciator .

If the file that shows connection don't display then ,

1)leds are connected to pin 8 and 9 respectively with a 220 ohm resistor as ballast

2) Door contact is pin 12 and Gnd with a 100K resistor as ballast

3) I used a momentary push button to simulate door state so at the 100k resistor and pin12 connection is one

side of a dry contact and the other side would go to Gnd

If you are using this to monitor a garage door and not using dry contacts I strongly recommend the use of a relay or an opto coupler, Arduino has a 20 mill amp max so you need to protect your board.

Please don't beat me up on this as I am totally new to this , I plan to expand this project to use WiFi that will report to my cell phone .Ask any questions and I will try my best to answer them

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Make It Bridge

      Make It Bridge



    Tip 2 years ago on Step 2

    I meant to include the fitrzing