Bonezegei XPT2046 : Simple Arduino Library for Resistive Touch
Bonezegei XPT2046 is a simple Arduino library for resistive touch screens based on the XPT2046 controller. The library provides functions to read the touch coordinates X, Y, and Z from the screen, as well as to calibrate the screen for accurate readings. The library is easy to use and compatible with ESP32. The library can be useful for developing applications that require user input or interaction with the touch screen. Follow the installation steps at https://bonezegei.com on how to install bonezegei libraries on Arduino IDE (Batutay, 2023).
1. Basic Usage
Simple demo for XPT2046 Sensor values
/* Author: Jofel Batutay Date: July 2023 XPT2046 Get Raw X, Y and Z ------------------------ | XPT2046PIN | ESP32 | | MOSI | 23 | | SCK | 18 | | MISO | 19 | | CS | 33 | Can be Assign to other pin | IRQ | 32 | Can be Assign to other pin -------------------------- */ #include <Bonezegei_XPT2046.h> #define TS_CS 33 #define TS_IRQ 32 Bonezegei_XPT2046 ts(TS_CS, TS_IRQ); void setup() { Serial.begin(115200); ts.begin(); } void loop() { ts.getInput(); Serial.print("X: "); Serial.print(ts.x); Serial.print(" Y: "); Serial.print(ts.y); Serial.print(" Z: "); Serial.println(ts.z); delay(10); }
References
- Batutay, Jofel. (2023). Arduino Library Installation. Bonezegei. https://bonezegei.com/?c=resources/tutorial&&d=resources/tutorial/libraries/install&&nav=1
Cite this
- Batutay, Jofel. (2023). Bonezegei XPT2046 : Simple Arduino Library for Resistive Touch. Bonezegei. https://bonezegei.com/?c=resources/tutorial&&d=resources/tutorial/libraries/bonezegei_xpt2046&&submenu=4&&nav=1