2.8″ TFT LCD Touchscreen Shield

Looking for a bigger screen to interface with the Arduino Uno? Bigger than the 2.4″ TFT LCD screen, this shield is able to display a little more information than the 2.4″ screen. In this tutorial, we’ll be looking at how we would interface the 2.8″ TFT LCD Touchscreen Shield with an Arduino Uno.

2_8_tft_main

Specifications

  • 2.8″ diagonal LCD TFT display
  • QVGA Resolution (240 X 320)
  • Graphic Driver: IL9341
  • MicroSD card slot
  • 4-wire resistive touchscreen
  • 8 bit digital interface, plus 4 control lines
  • 4 white LED backlight

Connections

As this is an Arduino Shield, just attach the shield to the Arduino Board. (Uno, Mega, etc.) But in this tutorial, we’ll be connecting the shield to an Arduino Uno.

Libraries

We’ll be using Adafruit’s GFX and TFTLCD library to interface the LCD shield with Arduino Uno. Download the library, extract the rspective folders and place it in your Arduino libraries directory.

Adafruit GFX Library: https://github.com/adafruit/Adafruit-GFX-Library

Adafruit TFTLCD Library: https://github.com/adafruit/TFTLCD-Library

 

Calibration

Before using the TFT LCD Shield, we should first calibrate the touch screen. As there weren’t any calibration sketch provided in the librarie’s example, I wrote a simple calibration sketch to calibrate the touch screen. With this sketch, adapted from Adafruit’s tftpaint example sketch, it will display the offset that will remap the  values of the raw values of the TFT resistors to the coordinates of the screen.

Demo

Code

The values displayed at the end of the calibration will be used to determine the TS_MINX, TS_MINY, TS_MAXX & TS_MAXY variables. These variables are actually the resistance value of the TFT screen, which will be “converted” into coordinates relative to the screen:

Upload the following code below to obtain the offset values. Remember to note down the respective values (TS_MINX, TS_MINY, TS_MAXX & TS_MAXY), as it is needed for the next section of the tutorial.

 

Paint Demo – Adjustments

After the calibration is done and the (maximum & minimum) X/Y  resistance values recorded, we’ll proceed on to running the tftpaint demo. Open up tftpaint sketch from Adafruit’s TFTLCD examples.

2_8disp_eg

Before uploading the code into Arduino, there are a few changes that needs to be done.

Touchscreen Constants

Replace the following constants with the values you have obtained from the calibration sketch, which is loacted at around line 51. So for example, if your values are:

  • Min X: 192
  • Min Y: 212
  • Max X: 915
  • Max Y: 891

Change the default constant values from:

to

 

Remapping

When you draw something on the touch screen with the original sketch, the X coordinates will be inverted. To fix it, we’ll have to flip the mapping function from :

to

 

Upload

After the changes has been made, save the sketch and upload to the Arduino. And Viola! You should be able to draw on the screen without too much offset.

 

Troubleshooting

The screen is blank/filled with noise!

Open up your serial monitor & see whther the library is able to detect the driver. If the Serial Monitor returns something like this:

You can try hard-coding the driver of the LCD Shield specific to the shield you have. You can figure it through these following methods:

  1. Turn to the back of the shield & look for the chip ID
  2.  Trying out all the possible IDs available in the TFTLCD Library one by one

After you have figured out the driver ID, we’ll hard code the driver ID. Modify this line of code (at line 92) from this:

to this:

 

Share this post:

You may also like...

Leave a Reply