How to convert char array to String

hi every one
im working on a door lock with password
i was succeed to develop that but the problem was if you had changed the password after reset the board password back to defult
now im working to use EEPROM to save password
i've tried to save String into EEPROM but the EEPROM.get Show Irrelevant chars
so i find out i have to save it in char array
now my problem is how to compare user input password with password i've read from EEPROM.get
or how to convert char array into String so i can use String class functions
Sorry for the messy code

#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const byte ROWS_COUNT = 4;
const byte COLUMNS_COUNT = 4;
char Keys_map [ROWS_COUNT][COLUMNS_COUNT] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
byte ROWS[ROWS_COUNT] = {2, 3, 4, 5};
byte COLUMNS[COLUMNS_COUNT] = {6, 7, 8, 9};
char inputKey = '&';
bool Check = false;
int del = 300;
char Saved_PASS[10];
char Input_PASS [10];
int door = 10;
bool PASS_Change = false;
char change_password [10];
int index = 0;
void setup() {
  lcd.setCursor(0, 0);
  lcd.print("*Enter PASSWORD*");
  pinMode(door , OUTPUT);
  digitalWrite(door, HIGH);
  EEPROM.get(0, Saved_PASS);

void loop() {
  inputKey = KeyCheck ();

void pinmode() {
  for (int i = 0; i < 4; i++) {
    pinMode(ROWS[i], OUTPUT);
    digitalWrite(ROWS[i], LOW);
    pinMode(COLUMNS[i], INPUT_PULLUP);

char KeyCheck () {
  char pressed_Key = '&';
  for (int j = 0; j < 4; j++) {
    if (digitalRead(COLUMNS[j]) == 0) {
      pinMode(COLUMNS[j], OUTPUT);
      digitalWrite(COLUMNS[j], LOW);
      for (int i = 0; i < 4; i++) {
        pinMode(ROWS[i], INPUT_PULLUP);
        if (digitalRead(ROWS[i]) == 0) {
          pressed_Key = Keys_map[i][j];
          Check = true;
          return pressed_Key;

void pass_Check() {
  if (inputKey >= '0' && inputKey <= '9' && Check == true) {
    Input_PASS[index] = inputKey;
    inputKey = '&';
    Check = false;

be aware of the fact that an EEPROM can do only 100.000 write-cylces until the EEPROM gets damaged.

If your code should happen to do repeated writing caused by bad programming you can wear out an eeprom within 15 minutes.

If you want safety about this use an SD-card or an FRAM-chip which can do much more write-cycles.

maybe it is easier for you you to use this library

read the documentation carefully and completely !

anyway you have to learn the basics about how variables are structured and how many bytes each variable type like int, long, float, and especcially string uses!
best regards Stefan

thank you but i want to learn it from basic as you mentioned
i would be grateful if you give me any clue

This forum IMHO is not to provide "covering-it-all-tutorials" always new for each user.

section about variables:

if you have read there come back with specific questions.

best regards Stefan

Why do any conversion ?
Read the user input into a string (lowercase s) and compare it with the string (lowercase s) read from the EEPROM using strcmp()

i can't figure it out
can you please give me sample code?

my problem is not reading or writing to eeprom
my problem is comparing two string (Saved_PASS and Input_PASS)

bool match = true;
for (int i = 0; i <10; ++i) {
if (Saved_PASS[i] != Input_PASS[i]) {
match = false;

The code you have posted has just one EEPROM.get()
not a single command about storing a password. And even if you would store a single byte this is not sufficient.

You seem to have not yet understood that the command eeprom.write() stores just a single byte while a array of char and a string contains multiple bytes.

This is why I recommend learning how variables work
best regards Stefan

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.