TFT LCD Display Screens interfacing

The 2.4″ Colour TFT display with micro SD card slot is now available as a SHIELD for Arduino UNO.
It has a four wire resistive touch screen, a micro SD card socket,a reset switch and a convenient arduino Uno shield footprint.
Specifications:
2.4 inch LCD TFT display has Bright, 4 white-LED backlight .
Colorful, 18-bit 262,000 different shades
4-wire resistive touchscreen
240 x 320 resolution
Spfd5408 controller with built in video RAM buffer
8 bit digital interface, plus 4 control lines
Uses digital pins 5-13 and analog 0-3. Digital pins 2, 3 and analog 4 and 5 are available  for user defined purpose.. Pin 12 is available if  micro SD is not used.
5V compatible, can be used  with 3.3V or 5V logic
Size: 71 x 52 x 7mm


       

For using this shield with Arduino we need a suitable library.The preinstalled TFT library that comes with the Arduino IDE uses SPI interface.
As SPI is slow for a screen size of 2.4” , this LCD uses parallel interface,though more pins are required.
LCD panel takes eight I/O pins ( 8-bit parallel data bus )  LCD_D0 to LCD_D7.
SD card needs another four — select, DI data in, DO data out and SCK  data clock.
But the LCD panel needs another five pins (RST,CS,RS,WR,RD) to control the eight-bit data bus, taking up five of the six analog I/O pins. So in the end, there’s just one analog I/O and two digital I/O pins left for other uses in your project
ADAFRUIT is the only TFTLCD library available.In this demo I’ve used the Adafruit library , as well as the modified library from

Download the following libraries :
1. Modified TFT SHIELD Library from Smoke and Wires
Extract the downloaded zip file & copy the folder named SWTFT-Shield  to the Arduino Libraries.

2. Adafruit GFX graphics core library, this is the ‘core’ class that all  other graphics libraries derive from
Rename the uncompressed folder as  Adafruit_GFX .It has a .cpp & a .h file .
Ensure that the Library folder name and the file names of .cpp & .h files inside the folder are the SAME.
If the name of the folder is different (even if you leave out the underscore) Arduino won’t recognize the keywords from the library.

3.Arduino library for 4-wire resistive touchscreens
Rename the uncompressed folder as TouchScreen.

Copy these 3 folders to C:\ProgramFiles\Arduino\Libraries
lcd4

You can download the library with all examples and bitmap image samples from HERE .
Unzip the downloaded folder & copy the 3 folders to libraries folder as seen in image above.Theimages inside the bitmap_images folder should be copied to the ROOT of Micro SD card.Do not copy as folder.Copy and paste inside SD card only the bitmap images.

—————————
Fix the LCD SHIELD on to the Arduino UNO carefully matching the pins.
       lcd6
Connect the USB cable to PC & open the Arduino IDE. Feed in the COM port allotted & select the board type as UNO.
Under File—>Examples –> SWTFT-Shield
you can see 4 sample codes for testing.If you do not see this under examples , check your Arduino Libraries directory for the folder SWTFT-Shield.The folder name  must be the same as that of the .cpp & .h files .
Let us test the sample examples now.
           LCD7
1. Load the sample code “graphicstest” on to the Arduino.
You can see the screen color changes and graphics display effect on LCD.
IMG_20141127_220854311      IMG_20141127_220903214

2. Now upload the second file “rotationtest

Open the Serial monitor of Arduino IDE & select Baud Rate as 9600  & New Line at the bottom .
On clicking on the Send button you can see Line,circle,dotted circle & Text at corners of thescreen.Every click displays at corners of the screen one by one.

lcd8

     IMG_20141127_221019436             IMG_20141127_221043195

3. Now let us test the 3rd example “ttfbmp “
It takes any 320-pixel wide 24-bit BMP image located in the root of the MicroSD card, loads it up & displays it.
Save any bitmap image BMP from your PC on to a Micro SD card using card reader.Make sure that the .bmp FILE SIZE does not exceed 250KB.You can make use of PC application like IRFANVIEW to resize the image & save as .bmp file of required size.If the file size is large “File not found” error will be the response.
Slide the Micro SD card into the slot at the back of the shield.
Load the 3rd example “ttfbmp” & see the result on the LCD screen.


IMG_20141128_081653823


4. Now upload the 4th example “ttfpaint “
Color pattern with 6 colors appear horizontally on the left side of screen.You can pick any color and draw or write on the touch screen.Do not use any sharp object to write as it will damage thescreen.Use a round edge stick and apply nominal pressure to write on screen.



Let us test a modified example to write on LCD screen from the Serial monitor of Arduino.
Upload the following code on to Arduino.
——————————————–
#include <Adafruit_GFX.h>    // Core graphics library
#include <SWTFT.h> // Hardware-specific library
char dataRx;
// Assign readable names to some common 16-bit color values:
#define    BLACK   0x0000
#define    BLUE    0x001F
#define    RED     0xF800
#define    GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
SWTFT tft;
void setup(void) {
  Serial.begin(9600);
  Serial.println(F("Type character in Arduino Serial port"));
delay(1000);
  tft.reset();
  uint16_t identifier = tft.readID();

  tft.begin(identifier);
  tft.fillScreen(BLACK);
  Serial.println(F("This is a serial data send Test!"));
  Serial.println(F("Type character in Arduino serial port & press <SEND> "));
}
void loop(void) {

    while (!Serial.available());
    dataRx=Serial.read();
    tft.setTextColor(YELLOW);
    tft.setTextSize(2);
tft.print(dataRx);

    }
————————————————————–
Open the Serial monitor .
Image 4

Type in some character & click on Send button.
You can see the characters displayed on the LCD screen.

1 comment:

  1. Thanks for sharing such an amazing article, really informative

    Visit here : LCD Display Screen

    ReplyDelete