#include <Keypad.h>
#include <DIYables_IRcontroller.h> // DIYables_IRcontroller library
#define LED 10
#define TRIG 11
#define ECHO 12
#define TRIG2 38
#define ECHO2 39
#define LED2 40
#define BUZZER 13
#define IR 41 // The Arduino pin connected to IR controller
const int WINDOWTHRES = 200;
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 4; //four columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},
{'*','0','#', 'D'}
};
byte pin_rows[ROW_NUM] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
DIYables_IRcontroller_17 irController(IR, 200); // debounce time is 200ms
const String password = "1234"; // change your password here
const String password2 = "5678";
String input_password;
void setup(){
Serial.begin(9600);
input_password.reserve(32); // maximum input characters is 33, change if needed
pinMode(LED, OUTPUT);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
irController.begin();
}
void loop(){
char key = keypad.getKey();
Key17 key20 = irController.getKey();
if (key){
Serial.println(key);
if(key == '*') {
input_password = ""; // clear input password
} else if(key == '#') {
if(input_password == password || input_password == password2) {
if (input_password == password){
delay(10000);
Serial.println("Arming");
}
if(input_password == password2){
Serial.println("Disarming");
}
// DO YOUR WORK HERE
} else {
Serial.println("password is incorrect, try again");
}
input_password = ""; // clear input password
} else {
input_password += key; // append new character to input password string
}
}
}