Re: Keypad for Gated Entry

GOT IT! Thanks. Here's the final twist. :slight_smile:

#include <Keypad.h>
#include <EEPROM.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns

char keys[ROWS][COLS] = { // Define the Keymap
{'1','2','3', 'A'},
{'4','5','6' ,'B'},
{'7','8','9', 'C'},
{'#','0','*' ,'D'}
};

int key = 0; //define key address in EEPROM
byte rowPins[ROWS] = { 9, 7, 4, 3 }; // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = { 1, 2, 10,5 }; // Connect keypad COL0, COL1, COL2, COL3 to these Arduino pins.

Keypad kpd = Keypad( rowPins, colPins, ROWS, COLS ); // Create the Keypad

int addr=0; //
void setup()

{
void loop()
{
char key = kpd.getKey();

if (key != NO_KEY){
Serial.println(key);
EEPROM.write (addr++, key);
if (addr == 2) {
addr = 0;
}
delay(100);
}
}

Serial.begin(9600);
}