Skip to content

Instantly share code, notes, and snippets.

@dhavalsavalia
Created April 1, 2019 05:02
Show Gist options
  • Save dhavalsavalia/91b460d49251691439868d1db3d4b051 to your computer and use it in GitHub Desktop.
Save dhavalsavalia/91b460d49251691439868d1db3d4b051 to your computer and use it in GitHub Desktop.
#include <Keypad.h>
const byte n_rows = 4;
const byte n_cols = 4;
char keys[n_rows][n_cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte colPins[n_rows] = {0, 4, 5, 16}; //connect to the row pinouts of the keypad
byte rowPins[n_cols] = {13, 12, 14, 2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, n_rows, n_cols);
int count = 0;
char c;
String id;
void setup(){
Serial.begin(115200);
}
void loop(){
char myKey = myKeypad.getKey();
if (myKey != NULL){
Serial.print("Key pressed: ");
Serial.println(myKey);
}
while(Serial.available()>0)
{
c = Serial.read();
count++;
id += c;
if(count == 12)
{
Serial.print("RFID ID:");
Serial.println(id);
break;
}
}
id="";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment