Source: https://mokxi.com/libraries/adafruit-ili9341
Updated: 2026-11-02

Libraries / Displays
Arduino library · Displays

# Adafruit ILI9341: a 320x240 color TFT on SPI

Adafruit ILI9341 drives the 2.4 and 2.8 inch color screens built on the ILI9341 controller, 240 by 320 pixels at 16 bits of color, many of them with a resistive touch panel and an SD card slot on the same board. It is a thin driver: the drawing and text calls come from Adafruit GFX, and this library adds the ILI9341’s start-up, rotation and fast pixel transfer.

Open the example in the editor See the calls

Built in on Mokxi: #include <Adafruit_ILI9341.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit ILI9341 does

The screen sits on the SPI bus. Its SCK and MOSI (often labeled SDI) go to the board’s SPI pins, MISO is optional, and three more pins are your choice: CS selects the screen, DC tells it whether a byte is a command or pixel data, and RST resets it. These modules are 3.3 V parts; on a 5 V Uno, the data lines need a level shifter or series resistors, or the screen stays white.

A full screen is 153,600 bytes of pixels, so redrawing everything is slow on an 8-bit board. The fast way to work is to draw the static parts once and then repaint only the small rectangles that change.

Library Manager name | Adafruit ILI9341

Author | Adafruit

Include | #include <Adafruit_ILI9341.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | TFT display, 240x320

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_ILI9341.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit ILI9341" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit ILI9341 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.6.1, so a sketch written here builds there too.

What to know in the simulator: readcommand8() answers from the commands sent, as there is no MISO. The PyPortal’s parallel-bus constructor builds, and begin() says on Serial that the parallel bus is not simulated.

ESP32-C3 · Arduino Uno · Arduino Nano · Arduino Mega 2560 · Arduino Leonardo · SparkFun Pro Micro · Arduino Micro · ESP32-C6 · Raspberry Pi Pico · Raspberry Pi Pico W · Seeed XIAO SAMD21 · STM32 · STM32 Nucleo-F411RE · STM32 Blue Pill · micro:bit V2 · Arduino Uno R4 · ESP32 DevKit · ESP32-S3-DevKitC-1 · ESP8266 NodeMCU · Arduino Pro Mini 3.3 V · Seeed XIAO ESP32-C3 · ESP32-C3 SuperMini · Seeed XIAO ESP32-C6 · ESP32-DevKitC V4 · LOLIN32 Lite · Wemos D1 R32 · Cheap Yellow Display · TTGO T-Display · Seeed XIAO ESP32-S3 · Arduino Nano ESP32 · Arduino Nano RP2040 Connect · Seeed XIAO RP2040 · Waveshare RP2040-Zero · Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_ILI9341 tft(10, 9, 8)

CS, DC and RST pins on the hardware SPI bus. Pass -1 for RST if it is tied to the board’s reset.

### tft.begin()

Starts SPI and sends the controller its set-up. Call it before any drawing.

### tft.setRotation(3)

Landscape (1 or 3) or portrait (0 or 2). In landscape the screen is 320 wide and 240 tall.

### tft.fillScreen(ILI9341_BLACK)

Paints the whole screen. ILI9341_RED, ILI9341_NAVY and the other ILI9341_ names are ready-made 16-bit colors.

### tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK)

Text color and the background behind each character, so changing numbers overwrite cleanly.

### tft.fillRect(x, y, w, h, color)

A filled rectangle from Adafruit GFX, the cheapest way to clear one area before redrawing it.

### tft.drawRoundRect(x, y, w, h, 8, ILI9341_CYAN)

An outlined button shape with rounded corners; with fillRoundRect() and centered text it makes a touch button.

## Example: Touch paint

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

Open it in the editor, wired and ready to run · Touch paint: the project page

## Common errors and how to fix them

### The screen lights up white and never shows anything

Usually the controller never got its set-up: CS or DC on the wrong pin, or 5 V logic on a 3.3 V module. Check the pins in the constructor, and level-shift SCK, MOSI, CS, DC and RST on a 5 V board.

### Colors are wrong or the picture is mirrored

The panel may not be an ILI9341. Many similar-looking modules use an ST7789 or ILI9488; read the chip name on the listing and use the matching library, such as Adafruit ST7789 or TFT_eSPI.

### Updating the screen takes most of a second

fillScreen() on every loop sends the whole frame. Draw the layout once in setup() and repaint only the rectangles with values that changed.

## Projects that use Adafruit ILI9341

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

Cap touch Draw on the 2.8 inch ILI9341 with its FT6206 capacitive touch panel, read with Adafruit’s library over I2C, and turn the film’s point round to match the screen.

## Keep going

### Learn

- Arduino ILI9341 TFT Display: Wiring and Code

### Parts

- TFT display, 240x320

### More displays libraries

- Adafruit SSD1306
- Adafruit GFX Library
- LiquidCrystal I2C
- LiquidCrystal
- LCD_I2C
- hd44780
- TFT_eSPI
- U8g2

Every built-in library · Open the editor

## Try Adafruit ILI9341 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
