What is the ILI9341 2.8" TFT?
The 2.8" ILI9341 TFT is the step up from small OLEDs: a 320 × 240 colour screen big enough for a real user interface, with a resistive touch panel on top and usually a microSD slot on the back, all for a few dollars. It talks over SPI, so it needs only a handful of pins, and the ILI9341 driver chip holds the whole image in its own memory, so your microcontroller only sends what changes.
The common red module is a 3.3 V logic device. That one fact decides how you wire it: an ESP32 connects directly, while a 5 V Arduino Uno needs level shifting on its outputs. This page explains the pinout, the voltage question, the three devices that share its SPI bus (display, touch, SD card), speed and memory limits, and which library to use. For code, see the Arduino Uno guide and the ESP32 guide.
Specifications
- Display
- 2.8" TFT, 320 × 240 pixels (QVGA), transmissive
- Driver chip
- ILI9341 with 172,800 bytes of built-in frame memory
- Colour
- 16-bit RGB565 (65,536 colours) over SPI; the chip also supports 18-bit
- Interface
- 4-wire SPI: SCK, MOSI, MISO (optional), CS, plus DC and RESET
- SPI clock
- 10 MHz in the datasheet; 27 to 40 MHz works on most modules in practice
- Touch
- 4-wire resistive panel, XPT2046 12-bit controller on SPI (2.5 MHz clock maximum)
- Storage
- microSD slot on its own 4-pin header (SPI)
- Module supply
- 5 V or 3.3 V on VCC: onboard 3.3 V regulator; short J1 to bypass it at 3.3 V
- Logic level
- 3.3 V. The common red module has no level shifter
- Current
- About 0.31 W (LCDwiki MSP2807 spec), roughly 60 mA at 5 V
- Backlight
- LED pin, active HIGH: tie it to 3.3 V for always on
- Active area
- 43.2 × 57.6 mm; module about 50 × 86 mm
Figures for the common red 2.8" SPI module (often marked TJCTM24028-SPI) and the ILI9341 / XPT2046 datasheets. Branded breakouts, such as Adafruit's, add level shifting and may use other pin names.
Pinout (14-pin header)
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Module power, 5 V or 3.3 V (see J1) |
| 2 | GND | Ground |
| 3 | CS | Display chip select, active LOW |
| 4 | RESET | Display reset, active LOW. Can be tied to 3.3 V if you are short of pins |
| 5 | DC / RS | Data / command select: LOW = command, HIGH = pixel data |
| 6 | SDI (MOSI) | SPI data into the display |
| 7 | SCK | SPI clock |
| 8 | LED | Backlight. 3.3 V for always on, or a GPIO / PWM pin for on-off and dimming |
| 9 | SDO (MISO) | SPI data out of the display. Only needed to read back from it; leave it off if it upsets other SPI devices |
| 10 | T_CLK | Touch SPI clock: join to SCK |
| 11 | T_CS | Touch chip select, active LOW |
| 12 | T_DIN | Touch data in: join to MOSI |
| 13 | T_DO | Touch data out: join to MISO |
| 14 | T_IRQ | Goes LOW while the screen is touched (optional) |
The separate 4-pin header on the other edge is the SD card: SD_CS, SD_MOSI, SD_MISO, SD_SCK.
Wiring & code
Setting up ILI9341 2.8" TFT with Arduino Uno
Library
Adafruit_ILI9341 by Adafruit
Library Manager: install "Adafruit ILI9341" (with Adafruit GFX Library and Adafruit BusIO), plus "XPT2046_Touchscreen" by Paul Stoffregen for touch
This guide runs the 2.8" ILI9341 touchscreen from an Arduino Uno. Because the Uno is a 5 V board and the display's logic is 3.3 V, the wiring goes through a level shifter; everything else is plug-and-play with the Adafruit libraries. You will run a graphics test, build a touch paint sketch with calibration, and learn the flicker-free way to show changing numbers, which matters on the Uno's 8 MHz SPI. Pinout and background are on the ILI9341 overview.
What you need
1Arduino Uno R3 (or Nano)
- Notes
- The Mega works too; its SPI pins are 50 to 53
12.8" ILI9341 SPI TFT with touch
- Notes
- The common red module
1CD4050 or 74HC4050 hex buffer
- Notes
- Level shifter powered from 3.3 V. Or six 1 kΩ / 2 kΩ divider pairs
1Breadboard and jumper wires
- Notes
- Keep SPI wires under about 15 cm
110 kΩ potentiometer (optional)
- Notes
- For the live value sketch, on A0
Wiring: ILI9341 to Arduino Uno
| Display pin | Uno pin | Through the level shifter? |
|---|---|---|
| VCC | 5V | No (J1 open) |
| GND | GND | No |
| CS | D10 | Yes |
| RESET | D8 | Yes |
| DC / RS | D9 | Yes |
| SDI (MOSI) | D11 | Yes |
| SCK | D13 | Yes |
| LED | 3.3V | No (always on) |
| SDO (MISO) | D12 | No: 3.3 V into the Uno is read as HIGH |
| T_CLK | D13 (with SCK) | Yes, same buffered line as SCK |
| T_CS | D4 | Yes |
| T_DIN | D11 (with MOSI) | Yes, same buffered line as MOSI |
| T_DO | D12 (with MISO) | No |
| T_IRQ | D3 | No (optional) |
Wiring the CD4050. Power its pin 1 from the Uno's 3.3V pin and pin 8 from GND. Each buffer has an input and an output: feed the Uno's D8, D9, D10, D11, D13 and D4 into six inputs, and take the six outputs to RESET, DC, CS, MOSI/T_DIN, SCK/T_CLK and T_CS. Because the CD4050 runs from 3.3 V, its outputs are 3.3 V even though its inputs accept 5 V. That uses all six buffers; if you add the SD card later, its SD_CS, SD_MOSI and SD_SCK lines need a second CD4050.
Using dividers instead? A 1 kΩ (from the Uno pin) and 2 kΩ (to GND) pair per line works. It can round off the SPI edges at higher speeds; if the image is garbled, shorten the wires or switch to the buffer.
Install the libraries
- 1Sketch > Include Library > Manage Libraries.
- 2Install "Adafruit ILI9341" and accept its dependencies "Adafruit GFX Library" and "Adafruit BusIO".
- 3Install "XPT2046_Touchscreen" by Paul Stoffregen for the touch sketches.
Sketch 1 - Graphics test
Text in three sizes, lines, a filled circle and a rounded rectangle: if all of these appear with the right colours, the wiring and level shifting are good.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST); // hardware SPI on D11 / D13
void setup() {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH); // touch CS high, so it ignores display traffic
tft.begin();
tft.setRotation(1); // 0-3: 1 = landscape, 320 x 240
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.setCursor(10, 10);
tft.println("SolderHub");
tft.setTextSize(2);
tft.setTextColor(ILI9341_YELLOW);
tft.println(" ILI9341 on an Uno");
tft.drawLine(0, 80, 319, 80, ILI9341_CYAN);
tft.fillCircle(70, 160, 45, ILI9341_RED);
tft.fillRoundRect(150, 115, 150, 90, 12, ILI9341_BLUE);
tft.setCursor(170, 150);
tft.setTextColor(ILI9341_WHITE);
tft.print("320x240");
}
void loop() {}How Sketch 1 works
| Call | What it does |
|---|---|
| Adafruit_ILI9341 tft(CS, DC, RST) | Uses the Uno's hardware SPI (D11 MOSI, D13 SCK) plus three control pins |
| digitalWrite(4, HIGH) | Parks the touch controller's CS so it ignores display traffic |
| tft.begin() | Resets the panel and sends the ILI9341 start-up sequence |
| setRotation(1) | Landscape. 0 and 2 are portrait (240 × 320), 1 and 3 landscape |
| fillScreen / fillRect | Writes every pixel in the area: the slow part on an Uno, so use it sparingly |
| setTextSize(n) | Scales the built-in 6 × 8 font; size 2 is 12 × 16 pixels per character |
| Colours (ILI9341_RED...) | 16-bit RGB565 values; tft.color565(r, g, b) makes your own |
Sketch 2 - Touch paint with calibration
The resistive panel reports raw numbers, roughly 200 to 3900 on each axis, not pixels. This sketch maps them to screen coordinates and draws a dot wherever you press. First run it as is and press the four corners: the Serial Monitor prints the raw values. Put the smallest and largest you see into the four constants, upload again, and the dots land under your stylus.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <XPT2046_Touchscreen.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
#define TOUCH_CS 4
// Raw touch range: replace with the values your corners print
const int RAW_X_MIN = 300, RAW_X_MAX = 3800;
const int RAW_Y_MIN = 300, RAW_Y_MAX = 3800;
Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST);
XPT2046_Touchscreen ts(TOUCH_CS);
void setup() {
Serial.begin(9600);
tft.begin();
tft.setRotation(1);
ts.begin();
ts.setRotation(1); // keep touch and display rotations the same
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(5, 5);
tft.print("Draw with a stylus. Tap top-left to clear.");
}
void loop() {
if (!ts.touched()) return;
TS_Point p = ts.getPoint(); // raw x, y and pressure z
int x = constrain(map(p.x, RAW_X_MIN, RAW_X_MAX, 0, 319), 0, 319);
int y = constrain(map(p.y, RAW_Y_MIN, RAW_Y_MAX, 0, 239), 0, 239);
Serial.print("raw "); Serial.print(p.x); Serial.print(", "); Serial.print(p.y);
Serial.print(" -> "); Serial.print(x); Serial.print(", "); Serial.println(y);
if (x < 30 && y < 30) { // corner tap clears the canvas
tft.fillScreen(ILI9341_BLACK);
delay(300);
return;
}
tft.fillCircle(x, y, 3, ILI9341_GREEN);
}Tip
If strokes appear mirrored, swap RAW_X_MIN and RAW_X_MAX (or the Y pair). If X moves when you move vertically, the axes are swapped: try another ts.setRotation() value until the dot follows the stylus.
Sketch 3 - Flicker-free live value
Clearing the screen and redrawing everything every loop makes an Uno-driven TFT flash badly, because a full fill takes about 0.2 to 0.3 s. The fix: draw the labels once in setup(), then in loop() update only the number and the bar, and only when the value has changed. Text drawn with a background colour overwrites the old digits in one pass.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST);
int lastValue = -1;
void setup() {
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_CYAN);
tft.setTextSize(2);
tft.setCursor(20, 20);
tft.print("Potentiometer on A0");
tft.drawRect(19, 149, 282, 32, ILI9341_WHITE); // bar outline, drawn once
}
void loop() {
int value = analogRead(A0) / 4; // 0-255, ignores tiny jitter
if (value == lastValue) return; // nothing changed: draw nothing
lastValue = value;
// Number: the background colour erases the old digits as it draws
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
tft.setTextSize(6);
tft.setCursor(20, 60);
char buf[5];
snprintf(buf, sizeof(buf), "%3d", value); // fixed width: no leftovers
tft.print(buf);
// Bar: fill the new part, clear the rest
int w = map(value, 0, 255, 0, 280);
tft.fillRect(20, 150, w, 30, ILI9341_GREEN);
tft.fillRect(20 + w, 150, 280 - w, 30, ILI9341_BLACK);
}Troubleshooting on the Uno
White screen
- Likely cause
- Logic not level-shifted, or CS/DC/RST pins differ from the sketch
- Fix
- Check the buffer is powered from 3.3 V and the pin numbers match
Works for a while, then white or garbled
- Likely cause
- Marginal levels or long wires
- Fix
- Use the CD4050 rather than dividers; keep wires short
Touch never registers
- Likely cause
- T_CS not on D4, or T_DO not joined to MISO (D12)
- Fix
- Check the touch lines join the SPI bus as in the table
Sketch does not fit or behaves randomly
- Likely cause
- Low RAM: GFX fonts and SD libraries use a lot
- Fix
- Avoid large custom fonts; check the free-memory figure the IDE reports
SD card fails once the display runs
- Likely cause
- SD card also needs 3.3 V logic and its own CS
- Fix
- Level-shift SD_CS, SD_MOSI and SD_SCK too, and hold unused CS lines HIGH
Arduino Uno FAQ
Can I skip the level shifter? Many people do and the display often works, but you are driving 3.3 V inputs with 5 V and relying on the chip's protection diodes. Expect white screens and a shorter life. The buffer costs less than the display.
Why is it so slow compared with videos I have seen? Those are usually ESP32s. The Uno's SPI tops out at 8 MHz and it has no RAM for a frame buffer, so full-screen redraws take a visible fraction of a second. Partial updates, as in Sketch 3, make it feel quick.
Does this work on the Mega? Yes, with SPI on pins 51 (MOSI), 52 (SCK) and 50 (MISO), and the same level shifting. The Mega's extra RAM helps with fonts and SD images.
Where next? The ILI9341 ESP32 guide shows the same screen running several times faster, or compare with the smaller ST7789 1.3" display.








