The LCD has a 3.5" 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.
Download Library
Begin by grabbing our analog/resistive touchscreen library from github (or just click the download button)
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 D8 and D7 since they are available.
Wire the additional 4 pins as follows:
- Y+ to Arduino A2
- X+ to Arduino D8
- Y- to Arduino D7
- X- to Arduino A3
Load up the breakoutTouchPaint example from the Adafruit_HX8357 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.
The image below shows the wiring, its for the 2.8" TFT but its the same wiring setup
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
Page last edited December 01, 2023
Text editor powered by tinymce.