1

Given:

const char* PROGMEM names[] = {"Foo","Bar"};
Serial.print(names[0]);

I get garbage output. Is there some function that will print the string from PROGMEM? E.G.:

Serial.print(<function name>(names[0]);
  • 1
    That's not how you use PROGMEM. You need to use the functions pgm_read_***_near – Gerben Feb 5 at 16:33
  • 1
    your strings are not in progmem. only the array of pointers to strings is there arduino.cc/reference/en/language/variables/utilities/progmem – Juraj Feb 5 at 18:26
  • Thank you for the pgm_read_byte_near reference. That tells me I need to pull data from PROGMEM a byte at a time. I realize now that I still do not know how to put foo and bar strings into PROGMEM without a run-time for loop. Is there a way to do this at compile time? – Bob Jones Feb 5 at 20:02
  • see the link in my comment – Juraj Feb 6 at 10:38
  • U can use String(names[0]) – Learner Feb 7 at 4:51
0

Among many others, check out pgmspace.h utilities at AVR-libc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.