What is the error code?

Hello, here's the thing, I would like to make castle with double protection (rfid card and password verification).
In programming is not strong and can not understand what is the error. Already tried a bunch of different versions of code. Stopped at this "cattle code".

Made so that the password or check marks made at any time, and then separately checked, but nothing is displayed after the correct password is entered.

#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] = {
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);

unsigned long uidDec, uidDecTemp; // for the premise of the label numbers in decimal format

void setup() {
 while (!Serial);
 Serial.println("Please enter password");
 karta = 0;
 klavishi = 0;
 tar = 0;

void loop() {
 //enter password 
 char key = klava.getKey();
 if (key){
 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() ){
 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");
July 9th 19 at 10:42
1 answer
July 9th 19 at 10:44
Let's start with the fact that you tar the variable is not reset to 0 after a set of six characters. And it would be necessary.
Tar is reset, but at the very end. Tried to drop immediately after the correct password is entered, this allows you to enter the password without checking the map. Map it is also normal checks. I have a suspicion that the program can not collect all in a single void in the sborka() - Marshall_Kuphal91 commented on July 9th 19 at 10:47
: and must be reset every time when you enter 6 characters, not when the password matches. If this is not done, beyond the bounds of the array, and this in C++ is undefined behavior, the controller can do what you want. - orin.Runte commented on July 9th 19 at 10:50

Find more questions by tags Arduino