I am completely new to Arduino. I have been given a side project to display a image from SD card to display. LCD used is ILI9486 which has a SD card slot at the back of the display module. I have inserted an 1 GB micro SD card. I am using below example code to try to open the SD card and display the image on display module. I am getting error on serial monitor "Initializing sd card - failed". Can anyone let me know how to display image from SD card to screen.

#include <SD.h>
#include <SPI.h>
#include <TFT.h>  // Arduino LCD library

// pin definition for the Uno
#define sd_cs  4
#define lcd_cs 10
#define dc     9
#define rst    8

TFT TFTscreen = TFT(lcd_cs, dc, rst);

// this variable represents the image to be drawn on screen
PImage logo;

void setup() {
    // initialize the GLCD and show a message
    // asking the user to open the serial line
    TFTscreen.background(255, 255, 255);

    TFTscreen.stroke(0, 0, 255);
    TFTscreen.println(F("Arduino TFT Bitmap Example"));
    TFTscreen.stroke(0, 0, 0);
    TFTscreen.println(F("Open serial monitor"));
    TFTscreen.println(F("to run the sketch"));

    // initialize the serial port: it will be used to
    // print some diagnostic info

    while (!Serial) {
        // wait for serial port to connect. Needed for native USB port only

    // clear the GLCD screen before starting
    TFTscreen.background(255, 255, 255);

    // try to access the SD card. If that fails (e.g.
    // no card present), the setup process will stop.
    Serial.print(F("Initializing SD card..."));
    if (!SD.begin(sd_cs)) {

    // initialize and clear the GLCD screen
    TFTscreen.background(255, 255, 255);

    // now that the SD card can be access, try to load the
    // image file.
    logo = TFTscreen.loadImage("arduino.bmp");
    if (!logo.isValid()) {
        Serial.println(F("error while loading arduino.bmp"));

void loop() {
    // don't do anything if the image wasn't loaded correctly.
    if (logo.isValid() == false) {

    Serial.println(F("drawing image"));

    // get a random location where to draw the image.
    // To avoid the image to be draw outside the screen,
    // take into account the image size.
    int x = random(TFTscreen.width() - logo.width());
    int y = random(TFTscreen.height() - logo.height());

    // draw the image to the screen
    TFTscreen.image(logo, x, y);

    // wait a little bit before drawing again
  • Most SD card modules don't allow other chips on the same SPI bus – chrisl Dec 29 '18 at 10:32
  • Hi, Thanks for the info. I was able to resolve the issue of initializing sd card failing. i made the sd_cs value as 10 and it worked. But now I am running into another problem. I am facing issue during loading of image from sd card. Getting error: "loadImage: file not found: arduino.bmp error while loading arduino.bmp" I am using 1 gb sd card and the size of bmp image is 7.5kb. its a 50x50 pixel 24 bit bmp image. What can be the problem? – KCI Dec 29 '18 at 11:06

Make sure your SD card is Fat16 format. At least that was a requirement of the test code I had on the same sort of display.

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.