Resistive Touchscreen

The LCD has a 2.8" 4-wire resistive touch screen glued onto it. You can use this for detecting finger-presses, stylus', etc. You'll need 4 pins to talk to the touch panel, and at least 2 must be analog inputs. The touch screen is a completely separate part from the TFT, so be aware if you rotate the display or have the TFT off or reset, the touch screen doesn't "know" about it - its just a couple resistors!

We have a demo for the touchscreen + TFT that lets you 'paint' simple graphics. There's versions for both SPI and 8-bit mode and are included in the libraries. Just make sure you have gone thru the TFT test procedure already since this builds on that.
Remember, if you rotate the screen drawing with setRotation() you'll have to use map() or similar to flip around the X/Y coordinates for the touchscreen as well! It doesn't know about drawing rotation

Download Library

Begin by grabbing our analog/resistive touchscreen library from github (or just click the download button)
Uncompress the zip file and rename the folder TouchScreen (make sure it contains Touchscreen.cpp and Touchscreen.h) then install in your libraries folder just like you did for the TFT library

Touchscreen Paint (SPI mode)

An additional 4 pins are required for the touchscreen. For the two analog pins, we'll use A2 and A3. For the other two connections, you can pin any two digital pins but we'll be using D9 (shared with D/C) and D8 since they are available. We can save the one pin by sharing with D/Cbut you can't share any other SPI pins. So basically you can get away with using only three additional pins.

Wire the additional 4 pins as follows:
  • Y+ to Arduino A2
  • X+ to Arduino D9 (Same as D/C)
  • Y- to Arduino D8
  • X- to Arduino A3
Load up the breakoutTouchPaint example from the Adafruit_ILI9341 library and try drawing with your fingernail! You can select colors by touching the 'pallette' of colors on the right

Touchscreen Paint (8-Bit mode)

Another 4 pins seems like a lot since already 12 are taken up with the TFT but you can reuse some of the pins for the TFT LCD! This is because the resistance of the panel is high enough that it doesn't interfere with the digital input/output and we can query the panel in between TFT accesses, when the pins are not being used.

We'll be building on the wiring used in the previous drawing test for UNO

You can wire up the 4 touchscreen pins as follows. Starting from the top
  • Y- connects to digital #9 (also D1)
  • The next one down (X-) connects to Analog 2 (also C/D)
  • The next one over (Y+) connects to Analog 3 (also CS)
  • The last one (X+) connects to digital 8. (also D0)
The X- and Y+ pins pretty much have to connect to those analog pins (or to analog 4/5) but Y-/X+ can connect to any digital or analog pins.
Load up the tftpaint example from the Adafruit_TFTLCD library and try drawing with your fingernail! You can select colors by touching the 'pallette' of colors on the right
Last updated on 2015-05-04 at 04.27.56 PM Published on 2014-03-18 at 04.50.41 PM