Problems displaying images when picking from array

So i'm using an Arduino to read a microSD card to display images onto a 2.2" TFT LCD screen.

I'm using 4 buttons to access different images on the SD card and display images on the screen.

This is working just fine, but the problem occurs when I want to display a random image from an array. I have the arrays as Strings with the file names, like such:

String answerImage = {
"a1.bmp", "a2.bmp", "a3.bmp", "a4.bmp", "a5.bmp", "a6.bmp", "a7.bmp", "a8.bmp", "a9.bmp", "a10.bmp"

However, I keep getting this error message:

"Cannot convert 'String' to 'char*' for argument '1' to 'void bmpDraw(char*, uint8_t, uint8_t)'"

The problem occurs here:

if (button1State == HIGH) {
// show cat images:
int imgNum = random(0, 9);
bmpDraw(answerImage[imgNum], 0, 0);

Your help is greatly appreciated!!!

Very simply, a String is not a string.
That's what the compiler is telling you.

Change you name array to be char pointers, not String pointers.

(And post all your code next time. Bonus points for use of code tags)

Hmm. Changing the "String" to "char*" stopped the error message.

However, now it will not display the images. It successfully tries to open a file, but now nothing happens.

Sorry, I'm also kind of a n00b. I tried to insert the code but it exceeded the max char length. Easier way to include it?

You could attach your code.

Here are the attached files. It’s slightly different than the code I posted earlier because the program keeps breaking.

Now, it currently says that it can’t find any of the files despite them still being on the SD card.

retrobox.ino (9.67 KB)

introscreen.ino (432 Bytes)

String answerImage [] = {
  "a1.bmp", "a2.bmp", "a3.bmp", "a4.bmp", "a5.bmp", "a6.bmp", "a7.bmp", "a8.bmp", "a9.bmp", "a10.bmp"

String memeImage [] = {
  "meme1.bmp", "meme2.bmp", "meme3.bmp", "meme4.bmp", "meme5.bmp", "meme6.bmp", "meme7.bmp", 
  "meme8.bmp", "meme9.bmp", "meme10.bmp"

String personalImage [] = {
  "pers1.bmp", "pers2.bmp", "pers3.bmp", "pers4.bmp", "pers5.bmp", "pers6.bmp", "pers7.bmp",
  "pers8.bmp", "pers9.bmp", "pers10.bmp"

String thoughtfulImage[] = {
  "t1.bmp", "t2.bmp" , "t3.bmp", "t4.bmp", "t5.bmp", "t6.bmp", "t7.bmp", "t8.bmp", "t9.bmp", "t1o.bmp"

You said you got rid of the Strings. You didn't.

I had replaced them with “char*”, but it didn’t work, so I changed them back

So change them back. You do not need to be wasting resources on Strings.

"It didn't work" is pretty lame, I'm afraid. Something happened. You expected something to happen. It's clear that those two somethings are not the same thing, but what either one is isn't clear.

Well, to elaborate more clearly, when I replaced them with "char*", the program would attempt to access the image file, however, it would not load. It would freeze the program and when I opened up the Serial Communication window I could see that it was attempting to open the image, but froze.

I don't see where you actually ever use those Strings. There are 6 calls to bmpDraw(), all with hard-coded names. The bmpDraw() function takes a char *, not a String.

A Serial.print() after the would tell you whether the file was found on the SD card, and could be opened. As it is, there is nothing after printing the file name until read16() completes with a specific value.

I’ve attached an updated version of the code I am attempting to get to work. I’ve changed one of the “Strings” to “char*”

If you refer to Button 4, that is where I’m trying to access the group of images. I’m trying to get it to open a random Image in the “answerImage” group.

When I have the Serial Communication window open, it even says it’s trying to open the image. However, nothing happens and the program locks at that point.

retroboxV2.ino (9.71 KB)

introscreen.ino (432 Bytes)

  // Open requested file on SD card
  if ((bmpFile = == NULL) {
    Serial.print("File not found");

  // Parse BMP header
  if(read16(bmpFile) == 0x4D42) { // BMP signature

That the message "File not found" does not appear does not mean that the file exist. If is possible that the method never returns. A Serial.print() statement after that block would be useful. Then, you'd know whether or not the file was opened.

I want to thank AWOL and Paul for the help. not only did it my project working, it helped me understand. "Quite simply, a String is not a string" . . . BAM. much appreciated.