Main Menu

search

You are here

TFT LCD touch screen shield

[last updated: 2016-10-19]

.

Current status: Breadboarded with substantial success to demonstrate operability of component, program, and libraries. Discovered some marginalities (shortage of available IO pins and possibly running out of ram) that may compromise adding it to a larger project.
-----

Disclaimer:
What I have here is just a record of my fumbling process. Pick out whatever data is valid for your situation, but don't consider it a tutorial or complete instruction set.

I bought several of these TFTLCD shields from BangGood, a Chinese importer. They're available other places as well. Very cheap. Hope I didn't get what I paid for. Mfr name on the board is mcufriend.com (A worthless mfr site unless you read Chinese. Did not seem to have a button to translate to English)

Mine was bundled with a R3 Uno:
BangGood Uno+TFTLCD

Here's their listing for just the TFTLCD:
BangGood TFTLCD

TFTLCD
touchscreen shield - back
TFTLCD
touchscreen shield - front
  • Very little documentation on this exact board was available.
    • When I bought mine, I could find very little, though it appears the BangGood site has more now.
    • Googled my way through forums and blogs and finally got it working
    • Almost everything available on the web was specific to the Adafruit TFTLCD breakout and shield. But their pin assignments didn't work for this board.
    • Could not find any sketches written for this board. In the end I started with the Adafruit sketches and edited them with pin assignments that worked for my board.
  • Programming:
    • Per instructions that I found, I downloaded the Adafruit libraries from Github: GFX, TouchScreen, and TFTLCD
    • The tftprint sketch in examples folder was where I started. Since my board is in fact a shield, I tried to run the tftprint_shield program, but it would not compile, appearing to detect that my shield was not Adafruit. However the tftprint worked, at least the graphics did, however the touch screen did not.
    • There are 4 pins used to read the touchscreen. The tftprint sketch assigned them as follows: XM=A2, XP=8, YM=9, YP=A3. As I said, this assignment did not work for my board.
    • After simple but tedious trial and error, I found these assignments worked: XM=A1, XP=7, YM=6, YP=A2.
      • With these pin assignments, the x-axis is parallel to the long side of the screen, and the y-axis along the short side. Interestingly, if you swap XM & YP, and swap XP & YM, everything still works, but the axes are flipped, with y along the long side and x on the short side.
      • Since I could not find any technical description of how these pins are used to extract x & y coordinates of touchscreen press and pressure, I have no idea if they are optimum or have unintended consequences, but they work.
      • The only thing I noticed is that there is interaction between the pins. That is, the x value that is returned when you press a spot on the screen varies with different y positions, and vice versa.
    • Per instructions on Adafruit, I measured the resistance between pins XM & XP and entered it in this line:
      TouchScreen ts = TouchScreen(XP, YP, XM, YM, [resistance]);
  • I wrote two programs to draw a grid of boxes. One has 4 boxes, the other 12. The 12-box program also senses where the screen was pressed, and blinks the color of the box that was pressed.
    • Because of the x & y interaction mentioned, I found it necessary to individually program the x & y mapping into the sketch. That is, if you want to program a response when box #4 is pressed, you open the serial monitor which prints out x & y coordinates of any press on the screen, then touch box 4 multiple times to find the range of values produced, and program those values into the sketch where you test for a press on that box.
  • Moving forward, I'm a bit concerned, though have not investigated sufficiently to know if my concerns are valid. The problem is, if you want to use this board for strictly visual things, then fine. But if you want to program your Arduino to do something outside, like light an LED, it appears there are very few Arduino pins not already dedicated to running the shield. First pass suggests the only ones available are D0, D1, & A5. More study needed.