Example Code for Arduino-Display BMP from SD Card

This project demonstrates how to display 16-bit RGB BMP images from a micro-SD card using the 3.5 TFT Resistive Touch Shield.

Hardware Preparation

Software Preparation

Wiring Diagram

  1. The 3.5 TFT Resistive Touch Shield connects directly on top of an Arduino pin compatible device.
  2. Insert the micro-SD card into the shield’s SD card slot.

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-TFT35-107). 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 <DmTftSsd2119.h>
 #include <DmDrawBmpFromSdCard.h>
 #define TFT_CS  10
 #define SD_CS   8
 #define F_CS    6
 #define T_CS    4
 DmTftSsd2119 tft = DmTftSsd2119(10, 9);
 DmDrawBmpFromSdCard drawImage = DmDrawBmpFromSdCard();
 void setup()
 {
  pinMode(TFT_CS, OUTPUT); // Set CS SPI pin HIGH for all SPI units, so they don't interfere
  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);
 }
 void loop() {
  drawImage.drawImage("logol565.bmp", tft, 0, 0);//Display picture
  delay(6000);
  drawImage.drawImage("logo1888.bmp", tft, 0, 0);
  delay(6000);
  }

Result

The shield will display the BMP images from the SD card in a loop (each image shown for 6 seconds).

Was this article helpful?

TOP