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.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.
Choose Your Method
- Arduino IDE
- PlatformIO
- Manual ZIP
The Library Manager is the easiest way to install and keep the library up to date inside the Arduino IDE.
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.Search for the library
Type
XPT2046_Touchscreen into the search box. The library by Paul Stoffregen will appear in the results.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.Dependencies
| Dependency | Required? | Notes |
|---|---|---|
Arduino SPI library | Yes | Bundled with every Arduino IDE and PlatformIO Arduino framework installation — no separate install needed. |
FlexIOSPI | Only on Teensy 4.x with FlexIO | Optional. 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: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.