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
- 2.8 TFT Touch Shield with 4MB Flash (SKU: DFR0347), Quantity: 1, Purchase Link: 2.8 TFT Touch Shield with 4MB Flash for Arduino and mbed(SKU:DFR0347)
- Arduino pin compatible device (e.g., Arduino Uno), Quantity: 1, Purchase Link: Arduino
- micro-SD card (supports micro-SD card), Quantity: 1
Software Preparation
- Arduino IDE (download link: Arduino IDE)
- DmTftLibrary (download link: dmtftlibrary)
- Installation guide for Arduino libraries: The official guide of Arduino
Other Preparation Work
It requires a special format for the displaying picture: 16bit RGBRGB bmp
You could download the convert tool here:ImageConverter

Anyway, there is converted picture in the library folder (DmTftLibrary\examples\DM-TFT28-105). You could have a try with it first.
-
Copy the converted picture to the SD.
-
Plug SD card in the touch screen.
-
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?
