Burglar Alarm

Hi, I’m a Year 2 Product Design student and for our brief we were tasked with creating a burglar alarm that communicates between two arduinos. The plan was to have one Arduino type a password to arm the system and send a singnal with a nrf radio to the another Arduino to begin sensing for movement and the alarm would go off when movement was sensed which would then send a signal to the Arduino with the keypad to enter a password to turn off the alarm. And I’m just looking for general guidance as I’m not well versed with Arduino.

Also the Arduino we are using is the Arduino Uno

This is the code I have for the keypad:

#include <Keypad.h>
#include <SPI.h>
#include <NRFLite.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
//define the symbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{‘1’,‘2’,‘3’},
{‘4’,‘5’,‘6’},
{‘7’,‘8’,‘9’},
{’*’,‘0’,’#’}
};
byte rowPins[ROWS] = {2, 7, 6, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {3, 8, 5}; //connect to the column pinouts of the keypad

// Radio Variables
byte chan = 1;
byte radio_id = 1; // this radio’s ID
byte send_id = 0; // the ID of the receiver radio
byte cepin = 9;
byte csnpin = 10;
byte radio_chan = 6; // please change this number to your group number

NRFLite radio; // this allows us to talk to the library in the sketch

byte counter = 0; // a variable to use to send some data

byte data_rx = 0;
unsigned long timerms = millis();

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

char inputArray[4]; //array to gather keypad presses from the user
char Password[4] = {‘2’, ‘3’, ‘4’, ‘7’}; //array to hold the correct password
int correct = A0; //shows where the green LED is connected on the Arduino
int incorrect = A1; //shows where the red LED is connected on the Arduino
int i = 0; //holds the numeric value
boolean msg = true;

int open()
{
digitalWrite(correct, HIGH); //turns the green LED on if the password is correct
digitalWrite(incorrect, LOW); //turns the red LED off when password is correct
Serial.println(“Alarm Armed”);
}

int MainPassword()
{
if((inputArray[0] == Password[0] && inputArray[1] == Password[1] && inputArray[2] == Password[2] &&
inputArray[3] == Password[3])) // input of password
{
byte message =1;
// sen[d message
open();
(radio.send(send_id, & msg, sizeof(msg)));
}
else
{
digitalWrite(incorrect, HIGH);
digitalWrite(correct, LOW);
Serial.println(“Incorrect Password”); //if password is incorrect
}
}//end MainPassword()

void setup()
{
Serial.begin(115200);
pinMode(correct, OUTPUT);
pinMode(incorrect, OUTPUT);

if (!radio.init(radio_id, cepin, csnpin, NRFLite::BITRATE2MBPS, radio_chan)) {
Serial.println(“Cannot communicate with radio”);
while(true); // Wait here forever.
}

unsigned long timerms = millis();

}//end Setup()

void loop(){
char password = customKeypad.getKey();
if (password)
{
inputArray = password;

  • i++;*

  • }*

  • if (i == 4)*

  • {*

  • MainPassword();*

  • {*

  • i = 0;// reset i*

  • }//end MasterPassword*

  • }//end if*

{

  • Serial.print("Loop count: ");*
    if(millis() - timerms >= 5000) {
  • timerms = millis();*
  • Serial.println(counter);*
  • Serial.println(“Sending loop count…”);*
  • if(radio.send(send_id, &counter, sizeof(counter))) { // & must be used in front of variable*
  • Serial.println("…Turn on Alarm");*
  • }*
  • else {*
  • Serial.println("…Failed");*
  • }*
  • counter++; // Add 1 to the counter variable*
  • }*
  • }//end if*

}//end loop()

Hello Shep2,
Welcome to the forum. Please read 'how to use this forum - please read', especially item #7. In case you can't find it, I should tell you it has been cunningly hidden in plain sight at the top of this and all the other forums, I can't imagine how you missed it.

Welcome !

We usually suggest that you get the Arduino working with one thing. then add another, then another.

Also, we really want you to try it out and see if you can get it to work. that way you learn.
Then, when you stumble, we can offer pointers and guidance to re-enforce your learning.

I am working on this. the indoor part is up and running; waiting on the proverbial slow boat from China for the outdoor part

general guidance:
it has to have a datalogger to be worth the aggravation
my sensors will flash a light when tripped. every part of the property is covered by video cameras. the flash will put an actual known accurate time on the video, in addition to the ridiculous clock in the DVR.
that datalogger needs to record at least which sensor was tripped, and when
opposing counsel will try to say that the clock was wrong. ergo, you need an undeniably accurate clock

so you are building a GPS clock with an RTC, and a datalogger, in addition to the alarm.

my system is for a gravel pit. 10+acres. my next project is long range ( optically ) and far away break beam sensors. this will require RF from the sensors to the Arduino. my current plan is sensor > pro mini > HC-12 modules > Arduino. the sensor package will send one byte to the Arduino, which will trigger the Arduino to perform the appropriate action for that sensor.