Arduino TFT LCD touch screen tutorial

Arduino TFT LCD Touch Screen
An LCD screen can makes your simple Arduino projects look a lot cooler. A typical Arduino TFT LCD touch screen can cost around £20 from Adafruit for instance. This is quite a considerable cost for simple projects. Fortunately, similar screens originating from China can be purchased on eBay for a fraction of the cost. For this post, we bought a 2.4″ Touch screen for £3.03! The screen came with no manual or datasheet and there was no sign of a model number. The only information was a website on the silkscreen on the PCB: “www.mcufriend.com”. The website is in Chinese, so after google translating it, we were able to download the Arduino Library for the screen. Posts found on Arduino.cc forums suggested that the Adafruit TFT library can also be used to control the screen.

Arduino TFT connections

Arduino TFT LCD Touch Screen connections
Online posts about this screen claim that it is only compatible with an Uno but we only had a Nano at hand. So we connected the screen to an Arduino Nano as follows:
Arduino TFT connections

We loaded the “graphictest” example from the Adafruit library and it didn’t work! All we got was a white screen. The graphictest example also prints out information on serial monitor. In our case, we got an “Unknown LCD driver chip: 0”. To fix this, we had to force the software to use the identifier 0x9341. All you need to do is to add the following line after the tft.readID() function call.

uint16_t identifier = tft.readID();
identifier = 0x9341;

Et voilà! it worked and we had images on the screen. We also tried the MCUFRIEND library but could not get that to work at all.

We proceeded to load the “tftpaint” example and to get that to work, we changed the default defined setting for YP, XM, YM and XP to:

#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

It should work after that. You may need to adjust your TS_MIN settings. We only had to change TS_MINY from 120 to 170 in our case. The code is available to download here: tftpaint_mod

If you have any questions or comments, please contact us at contact@behindthesciences.com

Tags:,

Add a Comment

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons