#include <keypad.h>
#include <servo.h>
#include <spi.h>
#include <mfrc522.h> // library for "RFID".
#define SS_PIN 10
#define RST_PIN 9
int tar; //variable to iterate through
char* password = "147923"; //password
const byte ROWS = 4; //number of rows to Claudia
const byte COLS = 4; // number of columns
char keys [ROWS] [COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
int klavishi; //for password authentication
int OK; //to check the card
byte rowPins[ROWS] = {16,17,18,19}; //where Conn
byte colPins[COLS] = {7,6,5,4};
// create the keyboard
Klava Keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
Metka MFRC522(SS_PIN, RST_PIN);
unsigned long uidDec, uidDecTemp; // for the premise of the label numbers in decimal format
void setup() {
Serial.begin(9600);
while (!Serial);
SPI.begin();
metka.PCD_Init();
Serial.println("Please enter password");
karta = 0;
klavishi = 0;
tar = 0;
}
void loop() {
//enter password
char key = klava.getKey();
if (key){
Serial.print('*');
if (key == password[tar]){
tar ++;
if (tar == 6){
klavishi = 1; //if the password is correct
}
}
}
{
//check the label
if ( ! metka.PICC_IsNewCardPresent() || ! metka.PICC_ReadCardSerial() ){
return;
}
}
int x=0;
uidDec = 0;
// The results of the serial number label.
for (byte i = 0; i < metka.uid.size; i++)
{
uidDecTemp = metka.uid.uidByte[i];
uidDec = uidDec * 256 + uidDecTemp;
}
if (uidDec == 2868417909){
karta = 1;
}
}
//combination of label and password
void sborka(){
if (klavishi == 1){
Serial.println(" correct password");
Serial.println("insert card");
if (OK == 1) {
Serial.println(" dostup razreshen");
delay (10000);
karta = 0;
klavishi = 0;
tar = 0;
Serial.println("Please enter password");
}
}
}</mfrc522.h></spi.h></servo.h></keypad.h>
Find more questions by tags Arduino