Keypad+LCD+multi-passcodes doable with UNO?

The overview:

LCD displays “Enter PassCode” on the top row with four " - " on the bottom. As a code is entered, the " - " are replaced by " * " on the bottom row for each button press. After four digit code is entered, press “#” on keypad.

If the entered code is one of multiple approved codes, “ACCESS GRANTED” appears on top row of LCD and a relay is closed.

-Once relay is closed, it remains closed until “*” is pressed on keypad.

If the entered code is one of multiple disallowed codes, “ACCESS DENIED” appears on top row of LCD and a relay remains open.

If the entered code is unlisted, “INVALID ENTRY” appears on top row of LCD and the relay remains open.

**I’d also really like to log accepted passcodes.

Is this doable? I’ve got an LCD shield from adafruit (uses I2C) and a keypad. I’ve been playing around with them both separately but I am having difficulty getting them to work together. Granted, I seem to be kind of… impaired with code so my integration attempts have just been splicing different sketches together. My latest attempt was to display which key was pressed on the LCD… it was an utter failure. haha

But I digress.

Am I missing anything? Will I need to use some sort of supplementary storage to have the passcode list and access log?

I know I’m new and fairly unskilled, but ambition’s gotta counts for something, right? XD

Thanks for any insight y’all may provide. Or Mockery; I accept mockery as well.

~Rev

Does it show on Serial Monitor which key is pressed? If yes, you can do a lot of interesting things.

What you are describing is doable, within limits. The passcode list you can keep with the code in PROGMEM, or in EEPROM. You can log to EEPROM, but there are only 1024 bytes to work with, so it's not much of a log.

For bigger logs it's popular to use SD card or an attached network device to log to a server.

-br

PunkoHead:
Does it show on Serial Monitor which key is pressed? If yes, you can do a lot of interesting things.

I am able to lightly modify an example sketch (all I do is change the row/col dealy and the pins used) to print to the serial monitor.

/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
#include <Keypad.h>

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

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

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
  }
}

This is actually the sketch I tried to combine with the adafruit LCD example. The idea was to change “Serial.print” to “lcd.print” but I encountered issues combining the two sketches.

billroy: What you are describing is doable, within limits. The passcode list you can keep with the code in PROGMEM, or in EEPROM. You can log to EEPROM, but there are only 1024 bytes to work with, so it's not much of a log.

For bigger logs it's popular to use SD card or an attached network device to log to a server.

-br

This is kind of what I thought. I figure I'll work on getting the original idea to work before I try adding more log storage.

Thanks for the input!

Okay, I'm starting to figure out how to interface the keypad with the LCD! Que happy dance! XD

I can now press a number on the keypad and it shows up on the LCD. (It's the little things in life. haha)

Now all you have to do is making the code like this: 1. Press a key. 2. Show on the lcd a "*". 3. Write and if-else statements: if (pressedkey==accesscode) { print on the lcd access granted} else print on the lcd access denied

Did you understand that? edit: for logging, you can use a usb connection and connect it with the PC. Loads of storage :)

PunkoHead: Now all you have to do is making the code like this: 1. Press a key. 2. Show on the lcd a "*". 3. Write and if-else statements: if (pressedkey==accesscode) { print on the lcd access granted} else print on the lcd access denied

Did you understand that? edit: for logging, you can use a usb connection and connect it with the PC. Loads of storage :)

Kinda sorta... mostly no. I have a feeling as I get further along, this will make perfect sense and I'll thank you again. (Haven't gotten to if-else understanding yet)

Thanks. :)

Post the code that you're using to show on the lcd a "*". Post the code for the keypad. I'll put them all along, and hopefully it'll work.

PunkoHead:
Post the code that you’re using to show on the lcd a “*”.
Post the code for the keypad.
I’ll put them all along, and hopefully it’ll work.

I was able to figure it out with the help of this tutorial.

Only had to tweak the sketch a bit.

my sketch so far;

/*
    Project Title: Numeric keypad with password and Serial Monitor
    Link: www.newtechandme.com
    Uses e-gizmo's development board
    Uses analog pin as digital pin
    Uses keypad library for Arduino http://www.arduino.cc/playground/uploads/Code/Keypad.zip
    Uses Password library for Arduino http://www.arduino.cc/playground/uploads/Code/Password.zip
    4/5/2012 Updates Nathan Sobieck: Nathan@Sobisource.com
    3/11/2013 updated by newtechandme.com
 
    LCD Connection
 * LCD RS pin to digital pin 14 (analog pin A0)
 * LCD Enable pin to digital pin 13
 * LCD D4 pin to digital pin 12
 * LCD D6 pin to digital pin 11
 * LCD D7 pin to digital pin 10
 * LCD D8 pin to digital pin 9
 * LCD R/W pin to ground
 
   Keypad Connection
 * ROW0 to digital pin 5
 * ROW1 to digital pin 4
 * ROW2 to digital pin 3
 * ROW3 to digital pin 2
 * COL0 to digital pin 8
 * COL1 to digital pin 7
 * COL2 to digital pin 6
 
 * LED to digital pin 15 (analog pin A1)
 
 Operation:
 '#' = OK -> checks if the password is correct or not
 '*' = CLEAR -> clears the password typed
*/
 
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h> 
#include <Password.h>
#include <Keypad.h>
#include <LiquidCrystal.h>

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield(); 
 
Password password = Password( "123456" ); //This is our password

 
const byte ROWS = 4; // 4 rows
const byte COLS = 3; // 3 columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
 
byte rowPins[ROWS] = {8, 7, 6, 5};// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = {4, 3, 2};// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
 
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 
void setup()
{
  pinMode(13, OUTPUT);
  lcd.begin(16, 2);
  lcd.setCursor(3,0);
  lcd.print("I like pizza");
  lcd.setCursor(3,1);
  lcd.print("yay!!")
  lcd.print("Work !");
  delay(2000);
  lcd.clear();
  lcd.setCursor(1,0);
  lcd.print("Enter PassCode");
  lcd.setCursor(0,1);
  lcd.print("Push # when done");
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}
 
void loop()
{
  lcd.setCursor(0, 1);
  keypad.getKey();
}
 
//check the keypad events
void keypadEvent(KeypadEvent keyPress)
{
  switch (keypad.getState())
  {
    case PRESSED:
    lcd.print(keyPress); //print the keypress
    switch (keyPress)
    {
      case '#':
            checkPassword();
          break;
 
          case '*':
            password.reset();
            digitalWrite(15, LOW);
            lcd.setCursor(0,1);
            lcd.print("                ");
          break;
 
          default:
          password.append(keyPress);
     }
  }
}
 
//check the entered password
void checkPassword(){
  if (password.evaluate()) //if password is correct
  {
    lcd.clear();
    lcd.setCursor(1,1);
    lcd.print("Access Granted"); //print a message on serial monitor
    digitalWrite(13, HIGH); //turn ON an LED
    password.reset(); //reset password
  }
  else
  {
    lcd.clear();
    lcd.setCursor(1,1);
    lcd.print("Access Denied."); //if password is wrong
    digitalWrite(12, HIGH); //blink an LED
    delay(1000);
    digitalWrite(12, LOW);
    delay(1000);
    digitalWrite(12, HIGH);
    delay(1000);
    digitalWrite(12, LOW);
    delay(1000);
    digitalWrite(12, HIGH);
    delay(1000);
    digitalWrite(12, LOW);
    password.reset(); //reset password
    lcd.clear();
    lcd.setCursor(1,0);
    lcd.print("Enter PassCode");
    lcd.setCursor(0,1);
    lcd.print("Push # when done");
  }
}

Still have to figure out how to incorporate multiple passwords and slightly different LCD behavior, but overall, I took a big leap last night toward the goal.

Huge thanks to all who helped me out so far.

~Rev.