/*
 * Created by ArduinoGetStarted.com
 *
 * This example code is in the public domain
 *
 * Tutorial page: https://arduinogetstarted.com/faq/how-to-input-a-multiple-digits-number-using-the-keypad
 */

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>

const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 3; //three columns

char keys[ROW_NUM][COLUMN_NUM] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte pin_rows[ROW_NUM] = {9, 8, 7, 6};   //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3}; //connect to the column pinouts of the keypad

LiquidCrystal_I2C   lcd(0x27, 16, 2);                                                 // Creates LCD   "object" (I2C address, rows, columns)

Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

String inputString;
long inputInt;
char key = keypad.getKey();
long randNumber;
bool run = true;
bool run2 = true;
bool run3 = true;


void setup() {
  Serial.begin(9600); // maximum number of digit for a number is 10, change if needed
  inputString.reserve(16); // maximum number of digit for a number is 10, change if needed

  // LCD Initialization
  lcd.backlight(); 
  lcd.init();
  lcd.clear();

  randomSeed(analogRead(0));
  randNumber = random(1000, 9999);
  Serial.println(randNumber);

kokot();
}

void loop() {
  
}

void kokot()
{
while (run2 = true)
{
  Serial.println("asdasdad");
}

while (run3 = true)
{
  Serial.println("xdzczczxczxc");
}
}





/*void passwordLogic()
{
  Serial.println("Enter Password");

  lcd.setCursor(2, 0);                                   //   Four is added to pressCount to center the input on the LCD
  lcd.print("ENTER:");
  lcd.setCursor(9, 0);
  lcd.print(randNumber);
  lcd.setCursor(0, 1);

  while (run = true)
  {
    char key = keypad.getKey();
    if (key) 
    {
    Serial.println(key);

    if (key >= '0' && key <= '9') 
    {     // only act on numeric keys
      inputString += key;
      lcd.print(key);              // append new character to input string
    }  

      if (inputString.length() == 4)
      {
      inputInt = inputString.toInt();
      if (inputInt == randNumber)
      {
         // YOU GOT AN INTEGER NUMBER
        inputString = "";               // clear input
        // DO YOUR WORK HERE
      Serial.print("defused");
      run = false;
      timerStart();
      }
      else if (inputInt != randNumber)
      {        
      inputString = "";
      Serial.print("wrong");
      lcd.clear();
      lcd.print("WRONG");
      delay(3000);
      lcd.clear();
      lcd.setCursor(2, 0);                                   //   Four is added to pressCount to center the input on the LCD
      lcd.print("ENTER:");
      lcd.setCursor(9, 0);
      lcd.print(randNumber);
      lcd.setCursor(0, 1);
      }
      }
    Serial.println(inputString);
    Serial.println(inputInt);
    }
  }
}

void timerStart()
{

}*/
4-Digit Display