Work with PROGMEM ?

Hi, can somebody help me with my code to put them in mem with PROGMEM

my constants char is…

#define maxItemSize 17
byte itemSelected, subMenuSelected;

char menu[][maxItemSize] ={"!! START !!","Ampere 2","Battery WET","Equalize OFF","MaintenanceOFF","Time","Voltage","Temperature","V / A reg.","Help","Reboot/Reset","BACK"," "};
char subMenu0[][maxItemSize] = {"WET Lead-Acid", "AGM", "GEL"}; //Baterry
char subMenu1[][maxItemSize] = {"Absorption", "Equalize","Maintenance", "RESET", "BACK"}; //Time of charge
char subMenu2[][maxItemSize] = {"0.5", "1", "2", "3", "4"}; // Ampere of charge
char subMenu3[][maxItemSize] = {"Float", "Absorption", "Equalize", "Maintenance", "RESET", "BACK"}; // Voltage of charge

//this is code to use char from menu and subMenu

itemSelected = displayMenu(menu, sizeof(menu)/maxItemSize);
subMenuSelected = displayMenu(subMenu0, sizeof(subMenu0)/maxItemSize);
subMenuSelected = displayMenu(subMenu1, sizeof(subMenu1)/maxItemSize);

how I can use PROGMEM with my code, how I can convert my code to use PROGMEM ?

somebady can help me ?

Have you tried here?

Or here.

This is how I do it

// Strings used in project stored in program memory
const PROGMEM char Msg_00[]= "!! START !!";
const PROGMEM char Msg_01[]= "Ampere 2";
const PROGMEM char Msg_02[]= "Battery wet";
const PROGMEM char Msg_03[]= "Equalize off";

All messages at top of sketch, easy to track them

To print a message centered on an LCD

lcd.printP (LCDLine_1, (int)(LCDCharsPerLine - strlen(Msg_07)) / 2, Msg_07, strlen(Msg_07));

To print a message on given line / column

lcd.printP (LCDLine_4, 1, Msg_80, strlen(Msg_80));

Finally the routine in my LCD lib

void LCD_ASI::printP (int Line, int Col, const char* Message, int Chars) {
// Sub to write a message from Flash to LCD at given location
 char _strDummy[Chars + 1];
 setCursor(Line, Col);

I hope this works for you too... ...


does not work on PROGMEM strings, use


Are you sure about that dear Whandall?
Because I copied the above from a working project!

I just changed the text to match the ones from the OP.

Probably it’s the compiler that evaluates the strlen at compile time before there is a difference in addressing,
it seems to work on PROGMEM strings, but I would still use the strlen_P.