Thursday, October 17, 2019

Garage Door is Still Open Reminder

Project Description.  

To prevent people forget to close their garage door, this project has been build to reminds people if their garage door has been open for more then 10 minutes.

As soon as garage door has been detected as "open", this device will start counting down for 10 minutes.  During counting down period it does not make any sound.  After 10 minutes is up, its buzzer will make "beeps" to reminder owner to close their garage door.

Feature: 
  1. Monitor the garage door is opened or closed.
  1. If the door is open for more then 600 second (10 min), its buzzer sounds reminder alarm.
Component List:
  • 1x Arduino Nano
  • 1x HC-SR04
  • 1x Yellow LED
  • 1x 5V Buzzer 
  • 1x 470 ohm LED resistor, (or any similar resistor)
  • Mini USB power supply
  • Wires
  • Project enclosure box


Schematic:



Result:




Arduino Code:
/* Garage Door Reminder Project
 *
 * Author: Samson Yang
 * Date: 10/19/2019
 *
 * Feature:
 *  1. Monitor the garage door is opened or closed
 *  2. If the door is open more then 600 second (10 min), it sounds "DOOR" mose code as the reminder alarm.
 *
 *  Pin Arrangement:
 *  D4 --> Door status yellow LED
 *  D7 --> US Trigger
 *  D8 --> US Echo
 *  D9 --> Buzzer
 *  
 *  
 *  Regarding <TimeLib.h>, please download zip from https://github.com/PaulStoffregen/Time and then add to Arduino's library
*/
#include <TimeLib.h>
bool buzer = 1;
int Pre_closing_alarm_time=600;   //after 10 minutes sound reminder
int Closed_Door_Threshold=600;  
long int count=0;


// the setup function runs once when you press reset or power the board
  pinMode(8, INPUT);    //Counting pin
  digitalWrite(4, LOW);
  //Test mode when pin 5 is high
  say_hi();
int door_open_time=0;
  //Check how much time the door has been opened
  //Door is opened
  //Send message out
  //Max frequency is 10Hz, or use 100 or higher value
bool check_door(){
  //Triger the signal
  //Measure the distance
  if (count_in<Closed_Door_Threshold)
void say_door(){
void say_door_is_open(){
void say_hi(){
void L(){
void S(){
void _(){


void setup() {
  Serial.begin(9600);
  pinMode(4, OUTPUT);   //Door status indicator
  pinMode(7, OUTPUT);   //Triger pin
  pinMode(9, OUTPUT);   //Alarm pin

  pinMode(5, INPUT);    //Test pin, 1: testing, 0:Normal

  digitalWrite(7, LOW);
  digitalWrite(9, LOW);

  if(digitalRead(5)){
    Pre_closing_alarm_time=3;
  }

}

void loop() {
  int time_gap=0;
  bool door_status = check_door();

  time_gap=now()-door_open_time;

  if (door_status) {
    digitalWrite(4, HIGH); //Turn on door status indicator LED
    if (time_gap>Pre_closing_alarm_time){
      //Remind door is open
      say_door();  //Option 1
      //say_door_is_open();//Option 2 
      //digitalWrite(9, buzer);buzer=!buzer;//Option 3
      }
    }

  else {
    //Door is closed
    digitalWrite(4, LOW); //Turn off door status indicator LED
    door_open_time=now();
    digitalWrite(9, LOW); //Turn off buzer
  }

  //Serial.print("");Serial.print("  ");
  //Serial.print(now());Serial.print("  ");Serial.println(door_open_time);

  delay(100);                    
}

  //if Closed return 0
  //if Opened return 1
  long int count_in=0;

  digitalWrite(7, HIGH);
  digitalWrite(7, LOW);

  //Wait ultra sound echo
  while (!digitalRead(8));

  while (digitalRead(8)){count_in++;}

    {return 1;}
  else
    {return 0;}
}

  //Say mose code D (it means done)
  L();S();S();_(); //D
  L();_();  //O
  L();_();  //O
  S();L();S();//R
  _();_();
}

  //Say mose code D (it means done)
  L();S();S();_();    //D
  L();_();            //O
  L();_();            //O
  S();L();S();_();    //R
  _();_();
  
  S();S();_();        //I
  S();S();S();_();    //S
  _();_();
  
  L();_();            //O
  S();L();L();S();_();//P
  S();_();            //E
  L();S();_();        //N
  _();_();
}

  S();S();S();S();_();S();S();
}

  digitalWrite(9, HIGH);
  delay(300);
  digitalWrite(9, LOW);
  delay(50);
}

  digitalWrite(9, HIGH);
  delay(100);
  digitalWrite(9, LOW);
  delay(50);
}

  digitalWrite(9, LOW);
  delay(300);
}

No comments:

Post a Comment