Pages: [1]   Go Down
Author Topic: "Security" System = Arduino+PIR+LCD+DS1307  (Read 2672 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello again...

I've been working on a project that has interested me ever since I got my hands on the Uno - my "home "security" system" (I put security in quotes mainly because, well, it's not really security, more so monitoring/indication). Anyways, I finished the project some time ago, and just a while ago, added the DS1307 RTC to it (just to add a little functionality/style, if you will). So, here is me showing it off a little bit smiley it's by no means perfect, and as usual, I welcome feedback and criticism. By no means does this project really secure anything. I would not recommend setting this up as a serious home security measure (unless you have the resources, in that case, more power to you!)
Here is the sketch;
Code:
/* BLUE/STR.BLUE - REED SW.
  PIR - Vs: STR.ORANGE, GND:BRN, OUT: STR.GRN
  Author - Gtr_Stitch
  01/27/2013

*/
#include <LiquidCrystal.h>
int piez = 8;
volatile int state = LOW;

LiquidCrystal lcd(4,5,6,7,9,10);
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;

void setup(){
  RTC.begin();
  Wire.begin();
  lcd.begin(16,2);
  attachInterrupt(0,sound,RISING);
  attachInterrupt(1,sound2,RISING);
  pinMode(3,INPUT);
  pinMode(11, OUTPUT);
  lcd.setCursor(0,0);
  lcd.print("--INITIALIZING--");
  lcd.setCursor(0,1);
  lcd.print(" PLEASE WAIT...  ");
  delay(30000); // give the PIR time to calibrate
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("    *ACTIVE*    ");
  delay(2000);
}

void indicator(){
  digitalWrite(11, HIGH);
  delay(250);
  digitalWrite(11, LOW);
  delay(250);
}

void trip_door(){
   lcd.setCursor(0,0);
   lcd.print("  BREACH  DOOR  ");
   indicator();
}

void trip_motion(){
    lcd.setCursor(0,1);
    lcd.print("     MOTION     ");
    indicator();
}

void loop(){
 
  int door = digitalRead(2);
  int pir = digitalRead(3);
  if ( door == LOW){
    trip_door();
  }
 
  else if ( pir == HIGH){
    trip_motion();
  }
 
  else {
  DateTime now = RTC.now();
 
  lcd.clear();
  lcd.setCursor(4,0);
  lcd.print(now.hour(), DEC);
  lcd.print(':');
  lcd.print(now.minute(), DEC);
  lcd.print(':');
  lcd.print(now.second(), DEC);
  delay(1000);
  }
}

void sound()
{
  tone(8, 500, 500);
}

void sound2()
{
  tone(8, 750, 500);
}

In a nutshell, the Uno monitors the PIR and a magnetic reed switch attached to the door downstairs. If either is tripped, a buzzer and a flashing led indicates motion or the door is open. When all is quiet, I query the time from the RTC, and a simple clock keeps the time. Pic down below. I used a very long cat5 cable to reach from downstairs to my computer desk. Because of the cat5's length, I've had some issues with interference, which I'm working on.

In another project, I fashioned a combination lock out of five push buttons and a servo. Maybe later on I'll incorporate that into this project. But that's another story smiley
'Til next time!

~Stitch


* WP_000781.jpg (141.81 KB, 717x538 - viewed 106 times.)
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

okay then...
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1328
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 Sorry that you did not get any responses. So many posts, so little time. You are on the right track. You have got a project to work that is practical and useful! You have also did a good job sharing your code and you provide a picture. I applaud your work and appreciate that you shared it!

 Don't worry to much about responses, they do not always represent the majority of people's opinions.
Logged


USA, FL
Offline Offline
God Member
*****
Karma: 14
Posts: 688
A life? Where can I download one of those?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree, with cycle, I come on this forum a few times a day and this is the first time I have seen this post.

Anyway, congrats on the working system!  You should post up a little tutorial on instructables or somewhere.  Lots of people have trouble getting a "security" system working.
Logged

//LiNK

London
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for this.
I have all the parts and hope to try your code out when I finish my current project.

Cheers,

Austin
Logged

Offline Offline
Faraday Member
**
Karma: 80
Posts: 3790
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would probably add an electrified net like Wolowitz rigged up for Sheldon's and Leonard's apartment....
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Johannesburg, South Africa
Offline Offline
Full Member
***
Karma: 0
Posts: 136
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Would you mind telling me which PIR you're using?
Logged

Pages: [1]   Go Up
Jump to: