Need Help with Arduino Keypad

I recently ordered this keypad:
Unfortunately, it has 8 pins while every tutorial I find only has code for 7 pins, which make more sense. I am unsure what the 8th pin is for and the 7 pin code doesn’t even come close to working for my keypad. Here’s the code I’m currently using:

#include <Keypad.h>
char* secretCode = "1234";
int position = 0;
const byte rows = 4;
const byte cols = 3;
char keys[rows][cols] = {
byte rowPins[rows] = {4, 5, 6, 7};
byte colPins[cols] = {1, 2, 3};
Keypad keypad = Keypad(makeKeymap(keys),
                       rowPins, colPins,
                       rows, cols);
int redPin = 12;
int greenPin = 13;
void setup()
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
void loop()
  char key = keypad.getKey();
  if (key == '*' || key == '#') {
    position = 0;
  if (key == secretCode[position]) {
  if (position == 6) {
void setLocked(int locked)
  if (locked) {
    digitalWrite(redPin, HIGH);
    digitalWrite(greenPin, LOW);
  else {
    digitalWrite(redPin, LOW);
    digitalWrite(greenPin, HIGH);

I’m very inexperienced with this code and may have bitten off more than I could chew. Any help you can provide would be much appreciated as I am completely lost and need to figure this out. Right now when I upload the code with everything wired up the red LED stays on permanently, no matter what button I press.

You need to find a wiring diagram for the keypad - what are the 8 wires connect to?

You can try and use a meter to find out which pair of wires are closed (and the rest are open) for every key press. That is you need to test 7+6+5+4+3+2+1 combinations whilst holding a key down. .. if you think about t long enough, you can write an sketch that will do that for you :slight_smile: Or search. I am sure someone already has done this (I did once for some other special switch... cant find the code, otherwise I would have attached it)

What is the code you posted doing? You don't know, because you don't have any Serial.begin() or Serial.print() statements, to show, for instance, what key is pressed (if any). And you may not be able to, because you have the device connected to one of the hardware serial pins. I can't imagine why.