Simple test sketch for UTouch library


Here is a simplest touch screen test sketch (display X,Y on serial) using UTouch library for common Arduino LCD shield.

#include <UTouch.h> UTouch  myTouch( 6, 5, 4, 3, 2); void setup() {   myTouch.InitTouch();   myTouch.setPrecision(PREC_MEDIUM);   Serial.begin(115200); } void loop() {   while (myTouch.dataAvailable())   {     myTouch.read();     long x = myTouch.getX();     long y = myTouch.getY();     if (x != -1 && y!=-1 && x != 319)     {       Serial.print("X=");       Serial.print(x);       Serial.print(" Y=");       Serial.println(y);     }   }   delay(20); }

Tested with XPT2046 / ADS7843 touchscreen driver on Arduino MEGA.

kit3-lcd35-2 kit3-lcd35-1
Newly released Telematics Shield with 3.5″ LCD (R61581 controller)

Comments are closed.