Hi,
I have recently bought Arduino Mega and a 7" TFT LCD Touchscreen
with a Shield compatible with the Touchscreen
https://www.amazon.ca/Akozon-Shield-Expansion-Screen-Display/dp/B07H2FKH73
I have written a simple code, that should make little squares where I touch the screen.
#include <UTFT.h>
#include <URTouch.h>
#define TOUCH_ORIENTATION PORTRAIT
extern uint8_t SmallFont[];
UTFT myGLCD(SSD1963_800ALT,38,39,40,41);
URTouch myTouch(6,5,4,3,2);
int buf[798];
int x=100;
int y=100;
void setup() {
randomSeed(analogRead(0));
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
Serial.begin(9600);
Serial.println("Hello World");
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
myTouch.InitTouch(PORTRAIT);
myTouch.setPrecision(PREC_MEDIUM);
myGLCD.clrScr();
myGLCD.setColor(130,120,0);
myGLCD.fillRect(x,y,x-5,y-5);
}
void loop(){
//Serial.println("0");
delay(50);
if (myTouch.dataAvailable()) {
Serial.println("1");
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
myGLCD.setColor(130,120,0);
myGLCD.fillRect(x,y,x-5,x-5);
}
}
It seem the display works normally (the square that should be made in setup() appears normally on the screen), but when I try to make squares where I touch the screen, myTouch.dataAvailable() does not trigger.
The setup for both UTFT and URTouch are (should be) correct. I tried both PORTRAIT and LANDSCAPE but neither has worked.
Also I tried to calibrate with URTouch_calibration and it also didn't work - when it showed me initial screen and when it called me to Touch screen to continue wherever I touched the screen nothing has happened.
The display also has a SD card reader which I haven't tried yet.
btw I'm newbie to arduino, please help me