Unknow charcter on lcd

Hello evrybody , i have a projet and i use for it rotary encoder and lcd i2c The problem is when working on the lcd sometimes, the lcd exposure uncknow character or the arduino reset it self I dont know what is the problem I dont think that the poor connection is the problem There is some Additional pictures I you need more information just let me know Thanks you ... :)

Sounds like poor connections or poor power supply.

No pictures or anything else (code, schematics) to go by for more detailed comments.

https://drive.google.com/file/d/14fAvQ2I6aksn3VN9CHdfJRPGkyai_kWs/view?usp=sharing

Does your code use Strings? Misuse of the String class can cause memory problems and random bugs and resets.

Does your code use arrays? Writing beyond the bounds of an array can cause the same sort of bugs.

Those are my best guesses without seeing your code. Read the forum guidelines before posting code.

Please read and follow the directions in the How to use this forum post.

Hi this is the part of code that i use in the array data and string

but what the solution to replace array and string in my code !!!!!

String  Strings[] = {"Automatic Mode","Manual Mode","Sound","Start","Back","ON","OFF","TONE","FiniSH Alarm","Repitition","SET AUTO UPPER ",      //
                       "LIGHT TIME","SET AUTO LOWER","Minute","Seconde","Operation Finish","After :","Set Light Time","To Start","Close Door",//
                       "Continue ??? :","NO","YES","Upper Light","Lower Light","Saving ...","Set and Close","Door To Start","Done","Close Door to","Continue","Operation is"};

and this is the part of Code where i called the string for lcd display

    lcd.setCursor(1,0);
    lcd.print(Strings[9]);
    lcd.setCursor(13,0);
    lcd.print(REP); 
    lcd.setCursor(1,1);
    lcd.print(Strings[4]);

Thanks you for you comment :) :)

If you are using a standard Arduino, avoid Strings. They cause program crashes and unexpected behavior.

Use C-strings (zero terminated character arrays) instead.

thanks you very much jremington that mean that i should add null character at last of each String if the problem is iliminated i will give a feed back thanks you very much for all ;) :)

that mean that i should add null character at last of each String

No, don't use Strings at all.

One way to declare and initialize a C-string is like the following. The compiler adds the terminating zero.

char cstring[] = "This is a C-string";

There are plenty of on-line tutorials, like this one.

Stated Simply

C-String <> String

C-String is an array of characters

String is an alpha-numeric variable that uses a special library to function. In small devices it causes more trouble than benefit.

To make matters (a lot) worse: the way you declared them, all that data gets stored in RAM during runtime. Of which you don't have much!

Declare them all separately, and store them in PROGMEM (see this tutorial on how that works). Then you can give the strings sensible names as well; I don't see any reason to stick them in an array other than making life hard on yourself as you have to time and again check what index prints what message, instead of just using the name.

By the way, don't worry too much about the null terminator. Be aware it must be there (so make your char arrays big enough); in most cases it's added automatically such as when you declare a string, often not actively added really as the default value of an element is 0 already.