Example Code for Arduino-Display SD Card Image

Last revision 2026/01/24

This article guides you through the process of displaying images stored on an SD card using an Arduino and a 2.8 TFT Touch Shield. It covers necessary hardware and software setup, provides a wiring diagram, and includes sample code to facilitate the integration, ensuring a seamless experience for users looking to enhance their Arduino projects with graphical displays.

Hardware Preparation

Software Preparation

Other Preparation Work

It requires a special format for the displaying picture: 16bit RGBRGB bmp
You could download the convert tool here:ImageConverter
DFR0347 2.8 TFT Touch Shield with 4MB Flash for Arduino and mbed Display a pictures from a SD card

Anyway, there is converted picture in the library folder (DmTftLibrary\examples\DM-TFT28-105). You could have a try with it first.

  1. Copy the converted picture to the SD.

  2. Plug SD card in the touch screen.

  3. Download the following program

Sample Code

 #include <SPI.h>
 #include <SPIFlash.h>
 #include <SD.h>
 #include <DmTftIli9341.h>
 #include <DmDrawBmpFromSdCard.h>
 #define TFT_CS  10
 #define SD_CS   8
 #define F_CS    6
 #define T_CS    4
 DmTftIli9341 tft = DmTftIli9341(10, 9);
 DmDrawBmpFromSdCard drawImage = DmDrawBmpFromSdCard();
 void setup()
 {
  // Set CS SPI pin HIGH for all SPI units, so they don't interfere
  pinMode(TFT_CS, OUTPUT);
  digitalWrite(TFT_CS, HIGH);
  pinMode(T_CS, OUTPUT);
  digitalWrite(T_CS, HIGH);
  pinMode(SD_CS, OUTPUT);
  digitalWrite(SD_CS, HIGH);
  pinMode(F_CS, OUTPUT);
  digitalWrite(F_CS, HIGH);
  Serial.begin(9600);
  tft.init();
  SD.begin(SD_CS);
  drawImage.drawImage("logop565.bmp", tft, 0, 0);//Display picture
  tft.clearScreen();
  delay(2000);
  drawImage.drawImage("logop888.bmp", tft, 0, 0);
 }
 void loop() { }

Was this article helpful?

TOP