How to Display Images on a TFT LCD
TFT LCDs, or thin-film transistor liquid-crystal displays, are a type of LCD commonly used in various devices, including smartphones, tablets, and TVs. TFT LCDs are known for their high image quality, fast response times, and low power consumption.
One of the most commonly used applications of TFT LCDs is displaying images. This makes them ideal for various projects, such as digital photo frames, digital signage, and DIY projects. In this article, we will show you how to display images on a TFT LCD using an SD card and the Arduino Due.
Dans cet article :
Things You Will Need
- Arduino Due Microcontroller Board
- 240x320 TFT with ST7789VI or equivalent IC (NHD-2.4-240320AF-CSXP)
- A 40-pin 0.5mm pitch FFC breakout board (NHD-FFC40)
- An SD card
- An SD card breakout board
- A breadboard
- Jumper wires
- A USB cable for the microcontroller
- Arduino IDE software
- LCD Image Converter software
Pinout Table
Complete pinout description and connections for the connection between the TFT LCD, SD card breakout board, and the Arduino Due.
TFT LCD and Arduino Due Pinout
LCD Pin | Symbole | Connection |
---|---|---|
1 | GND | GND |
2 | NC | NC |
3 | NC | NC |
4 | NC | NC |
5 | NC | NC |
6 | SDO | NC |
7 | VDD | 3.3V |
8 | VDDI | 3.3V |
9 | SDA | NC |
10 | CSX | GND |
11 | DCX | Arduino Pin 2 |
12 | WRX | Arduino Pin 11 |
13 | RDX | 3.3V |
14 | DB0 | NC |
15 | DB1 | NC |
16 | DB2 | NC |
17 | DB3 | NC |
18 | DB4 | NC |
19 | DB5 | NC |
20 | DB6 | NC |
21 | DB7 | NC |
22 | DB8 | Arduino Pin 33 |
23 | DB9 | Arduino Pin 34 |
24 | DB10 | Arduino Pin 35 |
25 | DB11 | Arduino Pin 36 |
26 | DB12 | Arduino Pin 37 |
27 | DB13 | Arduino Pin 38 |
28 | DB14 | Arduino Pin 39 |
29 | DB15 | Arduino Pin 40 |
30 | RESX | 3.3V |
31 | IM0 | 3.3V |
32 | IM2 | GND |
33 | GND | GND |
34 | LED-K1 | GND |
35 | LED-K2 | GND |
36 | LED-K3 | GND |
37 | LED-K4 | GND |
38 | LED-A | 3.3V |
39 | GND | GND |
40 | TE | NC |
SD Card Breakout Board Pinout:
SD Breakout Pin | Connection |
---|---|
GND | Arduino Due SPI Pin 6 |
MISO | Arduino Due SPI Pin 1 |
SCK | Arduino Due SPI Pin 3 |
MOSI | Arduino Due SPI Pin 4 |
CS | Arduino Due Pin 49 |
5V | Arduino Due SPI Pin 2 |
3.3V | NC |
Wiring Diagram
The wiring diagram below shows how to connect the TFT LCD and SD card to the Arduino Due for displaying graphics and accessing the SD card.
Convert Image to Text File & Save to SD Card
Most LCDs do not directly interpret standard image formats like JPEG or PNG. Instead, they use raw pixel data, often represented in hexadecimal format. We first need to convert the image to an image data array by downloading the LCD Image Converter software and following these steps:
- Open LCD Image Converter software.
- Go to Image -> Import and open the image you want to display on the LCD. Image file resolution must match the resolution of the LCD.
- Go to Options -> Conversion and ensure the “Color R5G6B5” preset is selected.
- Click on the “Image” tab. In the “Common” section, uncheck “Split to rows” and set block size to "8-bit."
- At the bottom-left of the window, click “Show Preview.”
- Copy and paste the hex values into a text editor and save the file as “image1.txt.”
- Transfer the text file to an SD card and insert the SD card into the breakout board.
Copy Example Code to Arduino IDE
Open the Arduino IDE and start a new Sketch. Clear any pre-existing code, then copy and paste the code provided below.
Upload the Code to Arduino
The final step is to upload the code to the Arduino IDE.
- Connect the Arduino to your PC with the USB-B cable.
- In the Arduino IDE, select the board and port.
- Click the “Upload” button to program the Arduino with your code.
Once the code is successfully uploaded, your image should appear on the LCD screen.
En savoir plus
For more tutorials and insights, check out our other posts:
Conclusion
Whether you are learning, prototyping, or want to have fun playing around with electronics, this tutorial outlines the basics of reading hex image data from an SD card and displaying it on a TFT LCD. This is only a starting point, and the possibilities for expansion are endless. We really hope you enjoyed this tutorial!
Derniers articles du blog
-
OEM vs ODM Manufacturing - Differences, Benefits, and Limitations
When outsourcing manufacturing, two terms come across: OEM (Original Equipment Manufacturer) and …Nov 26th 2024 -
Raspberry Pi Custom HDMI TFT LCD Timings
Setting up custom timing for HDMI TFTs and Touch HDMI Displays on Raspberry Pi can significant …Oct 29th 2024 -
Arduino vs Raspberry Pi: Key Features and Differences
If you're working on an electronics project—whether it's for a DIY automated device, a digital si …Sep 4th 2024