Thanks. I will post code in two posts. Meanwhile I'll work out a schematic...
I did mean reed switches. The PIR is happy with 12V per datasheet.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
// New7 - Removed beep function.
/*
ToDo:
New RJ11 Headers "C" for wn7 and pr7?
Once established, wire A0 to Audio Amp (connects via RJ11 "C")
Try to re-program G4 opener
Add functions for:
rd8 - Reed 8
LB8 - LED Blue
pr8 - PIR Outside
Fix wierd sounds!
*/
//*****************************************************************************************************************************************************************
// -1: InputPullup, 0: Not installed, 1: Input Positive, 2: OUTPUT
const int installed[20] = { 0, 0, 0, -1, -1, -1, -1, 2, 0, 0, 1, 2, 2, 1, 2, 2, 2, -1, 0, 0 };
const char* pinNames[20] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', "10", "11", "12", "13", "A0", "A1", "A2", "A3", "A4", "A5" };
const char* ssNames[20] = { "Rx", "Tx", "x", "mc7", "bo7", "dr7", "pb7", "PX7", "x", "x", "gl7", "LG8", "LR8", "pr8", "SPK", "SPX", "LB8", "rd8", "x", "x" };
const int bo7 = 4, pb7 = 6, PX7 = 7, LG8 = 11, pr8 = 13, SPX = A1, rd8 = A3 ;
const int mc7 = 3, dr7 = 5, gl7 = 10, LR8 = 12, SPK = A0, LB8 = A2;
// *****************************************************************************************************************************************************************
int arrMax = 20, beeps, beepLast, deBeounceMS, dirc, i, hertz, ledState, loops, mc7Reads, parsed, pr8Hits, pexUnlock, pirCount, beepOn, speaker, shoves, target, volume;
float loudBeeps, pirQ;
long unsigned doorMS, dsAlarmMS, pexPush, pirMS, pr8MS;
String eventName, eventOld;
int now[30] = { 0 } ; //Set prior to parse
int was[30] = { 0 } ; //Set after parse
int last[30] = { 0 }; //Millis of last trigger (state change)
const int deBounceMS = 30; // Debounce delay
const int delayMS = 15; //Loop Delay
const int loopsMax = 5; //Secondary Loop Divider
const int mc7ReadsMax = 20; // # loop delay for magnet contact alarm
const long unsigned noKeysDelay = 120000; // Delay to unlock once
const int delayDoorOpen = 30100; // Please Close Door Delay
const unsigned long pirDelay = 20123; // Duration to trigger PR8 alert
// Frequncies for event tones
const int hzCloseDoor = 400;
const int hzMagNonContact = 500;
const int hzNoKeys = 1200;
const int hzDoorShove = 700;
const int hzDoorOpen = 700;
const int hzBolting = 600;
const int hzPexPushed = 1100;
const int hzPirMotion = 200;
const int hzKeyIn = 1200;
const int hzDoorbell = 1600;
// Beep repetitions
const int repCloseDoor = 2;
const int repMagNonContact = 2;
const int repNoKeys = 4;
const int repDoorShove = 20;
const int repDoorOpen = 2;
const int repBolting = 1;
const int repPexPushed = 1;
const int repPirMotion = 1;
const int repKeyIn = 3;
const int repDoorbell = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pexPush = 99999999;
pexUnlock = 0;
doorMS = 999100200;
loops = 0;
loudBeeps = 0;
beeps = 0; //No. of beeps left in current tone pattern, zero at init.
beepOn = 0;
volume = 0;
for (i = 0; i < arrMax; i++) {
// Array init loop
// Set pin-modes based on installed flags
if (installed[i] == -1) {
pinMode(i, INPUT_PULLUP);
}
if (installed[i] == 0) {
pinMode(i, INPUT_PULLUP);
}
if (installed[i] == 1) {
pinMode(i, INPUT);
}
if (installed[i] == 2) {
pinMode(i, OUTPUT);
}
}
digitalWrite(PX7, LOW);
lcd.init();
lcd.print("Node 7 - Starting");
lcd.backlight();
}