Part

TFT display, 240x320

A 2.4 inch color TFT over SPI, for games and gauges.

See every part
  • 9 pins
  • In 5 projects
  • In 1 lesson
Drawn live by the editor's own code, at the size you see it.
At a glance

The TFT display, 240x320 in brief

What it is, and where it sits on the bench.

The ILI9341 drives the common 2.4 and 2.8 inch 240x320 color TFT breakouts, red boards with nine pins: VCC, GND, CS, RST, DC, SCK, MOSI, MISO and LED. It is SPI plus a DC line marking each byte command or data. On an Uno, SCK goes to 13, MOSI to 11 and MISO to 12, with CS and DC on any pins; on an ESP32 DevKit the SPI pins are 18, 23 and 19. VCC takes 5 V through a regulator, but the logic is 3.3 V, so a real module on a 5 V Uno wants a level shifter; an ESP32 drives it directly. Mokxi models the MIPI command set: CASET and PASET set a window, RAMWR streams RGB565 pixels into it, and the MV, MX and MY bits of MADCTL are all there is to setRotation(). The glass is the whole memory, so unlike the ST7735 and ST7789 there is no offset to get wrong. LED left low keeps the panel dark over a correct picture. Nothing is read back on MISO, the power and gamma tables are ignored, the 120 ms after SLPOUT is not enforced and there is no scrolling or backlight dimming.

Family
Displays
Pins
9

A circuit built around it, running and explained: the TFT display simulator.

Pins

9 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
Role
What it does
VCC
Input or output
Supply.
GND
Input or output
Ground.
CS
Input
Chip select, active low.
RST
Input
Reset.
DC
Input
Low for a command byte, high for its data or for pixels.
SCK
Input
SPI clock.
MOSI
Input
SPI data in.
MISO
Output
Present on the header, never driven; this model answers no register reads.
LED
Input or output
The backlight; pulling it low blanks the panel.
How to use it

How to use the ILI9341 2.4 inch TFT with an Arduino

Four signal wires and two straps, as in the Snake game beside this: CS to pin 10, DC to 9, SCK to 13 and MOSI to 11, with VCC, RST and LED all on 5 V. RST tied high just keeps the chip out of reset. LED is the backlight and a real pin: hold it low and the panel stays dark over a perfectly drawn picture. MISO can stay open, since nothing is read back.

Adafruit_ILI9341 compiles as it stands: construct it with the CS and DC pins, call begin() and setRotation(), then draw with the GFX calls. On an Uno every bit of every pixel is a pin change, so a full-screen fill takes a good part of a second. Snake repaints only the new head and the old tail each step, under three hundred pixels, which is what keeps it quick.

Part pin
Board pin
CS
Pin 10
DC
Pin 9
SCK
Pin 13
MOSI
Pin 11
RST
5 V
LED
5 V
VCC
5 V
GND
GND

Pong, two buttons drives the same panel from an ESP32-C3 at 3.3 V, with CS on GPIO 6, DC on 7, SCK on 4 and MOSI on 5. Adafruit_ILI9341 compiles on every board here but the ATtiny85.

Arduino Uno: Snake on a 2.4 inch TFTlive0.000 s 0.00x
Hold the button
This is the simulator itself, running here. Click anything to open it in the editor.
Text on the ILI9341 with the Adafruit calls
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
Adafruit_ILI9341 tft(10, 9);  // CS, DC; RST strapped to 5 V
void setup() {
  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_BLACK);
  tft.setTextColor(ILI9341_WHITE);
  tft.setCursor(10, 10);
  tft.print("Hello");
}
void loop() {}
How it is modeled

What is true about the TFT display, 240x320, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

MADCTL (command 0x36) is the whole of "rotation" on this controller: MV exchanges the two axes and MX/MY count the other way along them, and the frame handed to the display is always in the address counter's own coordinates, so the picture is upright whichever rotation the sketch chose. A module you rotate on the bench is a part you rotate on the canvas. CASET/PASET set the pixel window and RAMWR streams pixels into it, exactly as the datasheet has it.

Not modeled

BGR (a MADCTL bit some panels use for their color filter order) is accepted but has no effect: a pixel is always the RGB565 value that was written. The long init sequences every library sends (power control, gamma, frame rate, VCOM) are accepted and their parameters ignored, so a driver that sends a wrong or incomplete init gets a perfect picture here and whatever the panel feels like on the bench.

No timing at all on the bus. SCK has no maximum rate, CS has no setup or hold requirement, and a byte is latched the instant its eighth rising edge arrives. A real ILI9341 wants SWRESET followed by 5 ms of quiet and SLPOUT followed by 120 ms before it will take pixels; here both take effect immediately, so a driver that skips those waits works here and not on a real module. There is no frame rate, no tearing signal and no TE pin.

Also absent: vertical scrolling (0x33/0x37), partial mode, idle mode, tearing effect control, and gamma or VCOM having any visible effect. COLMOD accepts both 16-bit and 18-bit pixel formats, but a pixel is stored as RGB565 either way, so 18-bit mode loses the two extra bits per channel a real panel would keep. There is no backlight brightness. LED is on or off, not a PWM dimmer.

From ILI9341 color TFT, in full.

Projects

See the TFT display, 240x320 in a project

5 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

One lesson places it in its own circuit.

Boards

The boards it is shown on

Each of these 2 boards has a built-in project with the TFT display, 240x320 in it.

Libraries

Arduino libraries for the TFT display, 240x320

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the TFT display, 240x320

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.