Storing an array of strings in PROGMEM?

const char* text[] PROGMEM = 
"String 1",
"String 2",
"String 3"

I get error:

error: variable 'text' must be const in order to be put into read-only section.....

I searched this problem and some people say you have to put another “const” before the variable name?

Doing the above solution gives me 102% dynamic memory used?

I ran into this a while ago, the solution is here half way down the page on arduino:

I never actually got it to implement correctly so good luck! :smiley:


You can always do the following.

const char* text[] PROGMEM = "String 1String 2String 3";

and then just render the text at an offset.

1 Like

This is how we did it in Harambe’s revenge:

const char storyLine1[] PROGMEM = "Everyone lost a hero";
const char storyLine2[] PROGMEM = "the day Harambe";
const char storyLine3[] PROGMEM = "died.";   
const char storyLine4[] PROGMEM = "";                 
const char storyLine5[] PROGMEM = "Some thought it was";
const char storyLine6[] PROGMEM = "unfair.";
const char storyLine7[] PROGMEM = "Others took action!";
const char storyLine9[] PROGMEM = "In a far corner of";
const char storyLine10[] PROGMEM = "the world a plan was";
const char storyLine11[] PROGMEM = "hatched to enable...";

const char * const storyLines[] PROGMEM =

#define STORYLINES 12

And this is how we used the storyLines array:

char tBuffer[22];
arduboy.println(strcpy_P(tBuffer, (char*)pgm_read_word(&(storyLines[idx]))));

Note the size of the buffer. We could only fit 21 chars on a line using the smallest character size so each line is less than or equal to 21 chars. The 22 is to include the \x00 termination character.

it should be possible to do something like:
#define STORYLINES sizeof(storyLines)/sizeof(const char * )

To automatically calculate the number of lines so you don’t have to manually count. Was in a rush when I wrote the code and was having issues with automatically calculating so I just counted them.

We used a number of text arrays. Check out the full source if you need more examples.


That gives me error:

variable ‘text’ must be const in order to be put into read-only section by means of __attribute__((progmem))

Try it yourself.

remove the * since it’s not a pointer array.

1 Like

Did not work

For some reason I had success with this

const String text PROGMEM = {"String 1String 2String 3"};

I think the following guide shows how to do what you want:


Yeah sorry, i was giving an example not writing syntactically correct code, should have mentioned that :slight_smile:


I knew I’d seen atmel discussing this somewhere:

@Pharap, That’s just a reformatted version of what’s in the link I posted above.

1 Like