Lunch Pin Practice Tool

Hello all,

I am trying to make a practice lunch pad for a special education classroom. My ultimate goal is to make the overall experience mimic that of a regular lunch pin pad with a little extra. I have an Arduino UNO, 4x3 membrane keypad, and an Adafruit RGB LCD Pi Plate.

From combining two example code files I’ve found online I’ve managed to get the setup to give a welcome message, accept one password, light up green with the correct password, and red when a non-number is pushed.

I would like for the LCD to actively display the number input, be able to take multiple passwords, print a personalized message for each password, light up red when an incorrect password is made, and require a # to enter the password (I recognize this could be easily done by adding the # sign at the end of each password but I assume there’s a better way).


Example code for the Adafruit RGB Character LCD Shield and Library

This code displays text on the shield, and also reads the buttons on the keypad.
When a button is pressed, the backlight changes color.


// include the library code:
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
#include "Arduino.h"
#include "Keypad.h"

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

char* password ="1234"; //create a password
int k_pos = 0; //keypad position

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

// keypad map
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
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

Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){

  lcd.begin(16, 2);
  pinMode(RED, OUTPUT);  //set the LED as an output
  pinMode(GREEN, OUTPUT);
  setLocked (true); //state of the password


void loop(){

  char whichKey = myKeypad.getKey(); //define which key is pressed with getKey

  lcd.setCursor(0, 0);
  lcd.print("    Welcome");
  lcd.setCursor(0, 1);
  lcd.print(" Enter Password");

  if(whichKey == '*' || whichKey == '#' || whichKey == 'A' ||       //define invalid keys
  whichKey == 'B' || whichKey == 'C' || whichKey == 'D'){

    setLocked (true);
    lcd.setCursor(0, 0);
    lcd.print("  Invalid Key!");
  if(whichKey == password [k_pos]){

    k_pos ++;
  if(k_pos == 4){
    setLocked (false);
    lcd.setCursor(0, 0);
    lcd.print("*** Verified ***");
    lcd.setCursor(0, 0);
    lcd.setCursor(0, 1);
    lcd.print("You Did It!");

void setLocked(int locked){
    digitalWrite(RED, HIGH);
    digitalWrite(GREEN, LOW);
      digitalWrite(RED, LOW);
      digitalWrite(GREEN, HIGH);