2.4″ Touchscreen LCD Shield

Ever wanted to know how to make a simple drawing program on a LCD display, or are you curious about programming touch screens? Well, in this tutorial, we will be covering on how do you program a touchscreen display using the 2.4″ Touchscreen LCD sheild with Arduino Uno, which open up many possible applications which includes making a user friendly touch interface for making purchases, a simple touch-screen base remote control, and many more.

Overview

2_4_tft_touchshield_front

2.4″ TFT LCD Touchscreen Specs

  • QVGA Resolution (240 X 320)
  • Graphic Driver: IL9341
  • MicroSD card slot
  • 4 wire resistive touchscreen
  • A reset button on top

 

Parts required

  • Arduino Uno x 1
  • 2.4″ TFT LCD Touchscreen (with IL9341 Driver) x 1

 

Hooking it up

Hooking up the 2.4″ TFT LCD Touchscreen shield is realatively easy, since it is a Arduino shield. Just plug in the whole screen into the Arduino Uno, just note where the pins are located and connect the shield accordingly. There will be 2 parts in this tutoria, the first where you will test the functionality of the screen, and the next where you test the touch functionality of the screen.

 

Demo

In the demo, I combined the graphics demo and touch screen (or paint) demo together.

 

Graphic Test

For the graphics test of the 2.4″ screen, I used the sample sketch provided by the Adafruit TFTLCD library. The library can be downloaded here or here. (NOTE: You have to have the Adafruit GFX library installed before this library is installed, as the TFTLCD library uses the Adafruit GFX library for graphics. The library can be downloaded at https://github.com/adafruit/Adafruit-GFX-Library or here.)  A great thanks to Adafruit for their libraries.

2_4_touch_shield_2

Try uploading the example ‘graphictest’ sketch of the TFTLCD library. The screen should then be running the graphics test as shown above. If the screen displays nothing or displays only static, you may want to follow the steps taken below.

The modification I made in the example sketch is that I hard coded the LCD Driver, as for my case, the Arduino was unable to detect the LCD driver (and only produced noise on the screen).

Therefore, I set identifier variable as 0x9341 (located at line 60), which means that the shield is actually using a IL9341 LCD driver. Below are some useful links that may help if you encounter any difficulties:

 

Code

This is the hardcoded sketch. Please upload the ‘graphictest’ example sketch of the TFTLCD library. If there is static or no display, you may need to modify the ‘identifier’ variable depending on which LCD driver you are using. Below is a sample code of the LCD Driver hard coded.

 

Graphic test – Simple Paint Program

Open & upload the ‘tftpaint’ example sketch from the TFTLCD library. (You may want to calibrate the screen first before using it. To do so, visit this post where I written a calibration code which can be used in this example. However, please note that certain parameters have to be changed for the calibration sketch to work with this 2.4″ screen.)

If the sketch does not run properly, you may want to do the following modifications. For my case, I need to modify a few parts, which includes:

  • Hardcoding the LCD Driver
  • Flip the coordinates of the location pressed
  • Manual calibration

A useful link is provided below for reference.

 

Code

You can copy the modified code below:

 

Share this post:

You may also like...

6 Responses

  1. stonioit says:

    Hello,
    I read with interest your tutorial, I followed step by step and everything works properly. Now my problem is this. I would use arduino an RTC and the display 2.4 “MCUFRIEND to display the date and time on the display. However, the display uses the pin a4
    #define LCD_RESET A4
    but the RTC module uses both the pin A4 and A5 is the pin for I2C communication.
    It would be possible to replace the statement
    #define LCD_CS A3
    #define LCD_CD A2
    #define LCD_WR A1
    #define LCD_RD A0
    // optional
    #define LCD_RESET A4

    for example with the digital pins as follows?

    #define LCD_CS 2
    #define LCD_CD 3
    #define LCD_WR 4
    #define LCD_RD 5
    // optional
    #define LCD_RESET 6

    I do not need to use the touch screen nor the sd, but I would use the display to view only information coming from various sensors i2c

    An example would be very welcome.
    Thank you

    • WK says:

      Hi,
      Which Arduino are you using & what is the version of it? If you are using Arduino Uno Rev.3, there is actually a I2C pins located above the AREF pin. (Digital pins side). If not, I think it should be possible to use the digital pins for the SPI communication of the LCD display.

  2. aprada66 says:

    DUPLICATED (DOUBLED) IMAGE

    Hi. I tested all examples, but image is doubled, (out twice), in the top and bottom of the screen. How to solve

Leave a Reply

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