Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/PaulStoffregen/XPT2046_Touchscreen/llms.txt

Use this file to discover all available pages before exploring further.

XPT2046_Touchscreen can be installed through the Arduino IDE’s built-in Library Manager, PlatformIO’s dependency system, or by manually importing a ZIP archive from GitHub. All three methods result in an identical installation — choose whichever fits your workflow.
Arduino IDE 1.6.0 or later is required. The library header enforces this with a compile-time #error and will refuse to compile on older IDE versions that ship an incompatible SPI library.

Choose Your Method

The Library Manager is the easiest way to install and keep the library up to date inside the Arduino IDE.
1

Open the Library Manager

In the Arduino IDE, go to Sketch → Include Library → Manage Libraries… (or press Ctrl+Shift+I / ⌘+Shift+I). The Library Manager panel will open and index available libraries.
2

Search for the library

Type XPT2046_Touchscreen into the search box. The library by Paul Stoffregen will appear in the results.
3

Install

Select the latest version from the drop-down (1.4 at time of writing) and click Install. The IDE downloads and unpacks the library into your Arduino libraries/ folder automatically.
4

Verify

After installation, go to File → Examples → XPT2046_Touchscreen and confirm that the TouchTest example appears in the menu.

Dependencies

DependencyRequired?Notes
Arduino SPI libraryYesBundled with every Arduino IDE and PlatformIO Arduino framework installation — no separate install needed.
FlexIOSPIOnly on Teensy 4.x with FlexIOOptional. The library auto-detects its presence via #if __has_include(<FlexIOSPI.h>) and enables FlexIO support only when the header is found.
No other third-party libraries are required. The XPT2046_Touchscreen library deliberately avoids Adafruit GFX or any display driver dependency so it can be used independently of whichever TFT rendering library you choose.

Including the Library in Your Sketch

Once installed, add these two includes at the top of every sketch that uses the touchscreen:
#include <SPI.h>
#include <XPT2046_Touchscreen.h>
SPI.h must be included before XPT2046_Touchscreen.h so that the SPI types are defined when the touchscreen header is processed. The Arduino IDE typically handles include ordering automatically when you use Sketch → Include Library, but it is good practice to list SPI.h first.

Build docs developers (and LLMs) love