Hi,
Need some help getting the touchscreen XPT2046 to work with PS's XPT2046_Touchscreen.h library. PS XPT2046 Lib
Here is the schematic for the ELECROW 2.4" module:
Elecrow 2.4 Manuf Link"
Here is the example sketch from the library with pinout settings:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 33
// MOSI=11, MISO=12, SCK=13
XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN 36
//XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
// XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
void setup() {
Serial.begin(115200);
ts.begin();
ts.setRotation(1);
while (!Serial && (millis() <= 1000));
}
void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}
Here's the Serial Monitor Output:
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
Pressure = 4095, x = 8191, y = 8191
(continues to repeat)
The challenge appears to be in the SPI settings not matching... Here are the ELECROW hardwiring:
MISO 12
MOSI 13 vs lib MOSI=11
SCLK 14 vs lib SCK=13
CS 33
DC 2
Is there a way to change the identification of the SPI pinouts in this library?
Thanks
