Created
June 18, 2013 18:10
-
-
Save gtrstitch/5807834 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* 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(){ | |
pinMode(13, OUTPUT); | |
RTC.begin(); | |
Wire.begin(); | |
//RTC.adjust(DateTime(__DATE__, __TIME__)); | |
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(300); // give the PIR time to calibrate | |
lcd.clear(); | |
lcd.setCursor(0,0); | |
lcd.print(" *ACTIVE* "); | |
delay(2000); | |
digitalWrite(13, HIGH); | |
} | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment