2.8" TFT (mcufriend clone) touch not working with Arduino Uno R3

I’m new to the Arduino. I have an Arduino Uno R3 with the IDE 1.8.1 and a 2.8" TFT LCD from ebay with identical pins as the www.mcufriend.com 2.8" TFT LCD.

I’m able to write graphics code to the shield successfully.

Now I’m trying to run the Adafruit_TFTLCD\examples\tftpaint2 sketch (code is attached) but the touch doesn’t seem to work.

When I run the sketch it shows it’s the 9431 controller and it outputs 8 boxes across the top of the shield but it does not respond to touch.

Is there any diagnostic code I could add that would tell me if the screen is good?


tftpaint2.ino (10.1 KB)

I solved my own problem so I'm posting the solution for others.

The touch screen pins for my shield had to be defined as:

#define YP A3 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin