Want to add 4*4 matrix keypad with maga board as per given block diagram

i want to add a 4*4 matrix door lock keypad with my Arduino mega as per below block diagram . & i want to give manually password input … i cant find any suitable option so … is it possible through Cayenne
Need help …

Sure, it’s possible. Do you have any code so far? If so post it and I’ll make some suggestions. I have one of these laying around so I can test.

1 Like

Yes, its possible, you only need to use this statements:
customKey = customKeypad.getKey(); and key = customKeypad.waitForKey();
If you don’t know how to use them I can give you an example of a loop to get the password.

1 Like

yes , i already done this … and it work properly…

#include <Keypad.h>
#include <Servo.h>
#include <LiquidCrystal.h> //include LCD library (standard library)

//#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneEthernet.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "xxxxxxxxx";

Servo servo_Motor; 
char* password = "123";
int position = 0;
const byte ROWS = 4; 
const byte COLS = 4; 
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[ROWS] = { 23, 25, 27, 29 };
byte colPins[COLS] = { 31, 33, 35, 37 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal lcd (A0, A1, A2, A3, A4, A5); // pins of the LCD. (RS, E, D4, D5, D6, D7)
int redPin = 53;
int greenPin = 52;

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(token);
  
  lcd.begin(16, 2);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
servo_Motor.attach(11);
setLocked(true);
}

void loop()
{
  Cayenne.run();
  
char key = keypad.getKey();
lcd.setCursor(0, 0);
  lcd.print("    Welcome");
  lcd.setCursor(0, 1);
  lcd.print(" Enter Password");
if (key == '*' || key == '#')
{
position = 0;
setLocked(true);
lcd.setCursor(0, 0);
  lcd.print("    Welcome");
  lcd.setCursor(0, 1);
  lcd.print(" Enter Password");
  lcd.clear();
} 
if (key == password[position])
{
position ++;
}
if (position == 3)
{
setLocked(false);
lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("*** Verified ***");
    delay(2000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("  Rajendra");
    lcd.setCursor(0, 1);
    lcd.print("Home security Door lock");
    delay(3000);
    lcd.clear();
}
delay(100);
}
void setLocked(int locked)
{
if (locked)
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
servo_Motor.write(12);
}
else
{
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
servo_Motor.write(90);
}
}
1 Like