Colour TFT LCD modules just keep getting cheaper, so in this tutorial we’ll show you how to get going with some of the most inexpensive modules we could find. The subject of our tutorial is a 2.8″ 240 x 320 TFT module with the ILI9325 LCD controller chip. If you look in ebay this example should appear pretty easily, here’s a photo of the front and back to help identify it:

There is also the line “HY-TFT240_262k HEYAODZ110510” printed on the back of the module. They should cost less than US$10 plus shipping. Build quality may not be job number one at the factory so order a few, however considering the cost of something similar from other retailers it’s cheap insurance. You’ll also want sixteen male to female jumper wires to connect the module to your Arduino.

Getting started

To make life easier we’ll use an Arduino library “UTFT” written for this and other LCD modules. It has been created by Henning Karlsen and can be downloaded from his website. If you can, send him a donation – this library is well worth it. Once you’ve downloaded and installed the UTFT library, the next step is to wire up the LCD for a test.

Run a jumper from the following LCD module pins to your Arduino Uno (or compatible):

DB0 to DB7 > Arduino D0 to D7 respectively

RD > 3.3 V

RSET > A2

CS > A3

RW > A4

RS > A5

backlight 5V > 5V

backlight GND > GND

Then upload the following sketch – Example 50.1. You should be presented with the following on your display:

If you’re curious, the LCD module and my Eleven board draws 225 mA of current. If that didn’t work for you, double-check the wiring against the list provided earlier. Now we’ll move forward and learn how to display text and graphics.

Sketch preparation

You will always need the following before void setup():

Arduino

1

2

#include "UTFT.h"

UTFTmyGLCD(ILI9325C,19,18,17,16);// for Arduino Uno

and in void setup():

Arduino

1

2

myGLCD.InitLCD(orientation);

myGLCD.clrScr();

with the former command, change orientation to either LANDSCAPE to PORTRAIT depending on how you’ll view the screen. You may need further commands however these are specific to features that will be described below. The function .clrScr() will clear the screen.

Displaying Text

There are three different fonts available with the library. To use them add the following three lines before void setup():

Arduino

1

2

3

externuint8_tSmallFont[];

externuint8_tBigFont[];

externuint8_tSevenSegNumFont[];

When displaying text you’ll need to define the foreground and background colours with the following:

Arduino

1

2

myGLCD.setColor(red,green,blue);

myGLCD.setBackColor(red,green,blue);

Where red, green and blue are values between zero and 255. So if you want white use 255,255,255 etc. For some named colours and their RGB values, click here. To select the required font, use one of the following:

Arduino

1

2

3

myGLCD.setFont(SmallFont);// Allows 20 rows of 40 characters

myGLCD.setFont(BigFont);// Allows 15 rows of 20 characters

myGLCD.setFont(SevenSegNumFont);// allows display of 0 to 9 over four rows

Now to display the text use the function:

Arduino

1

myGLCD.print("text to display",x,y);

where text is what you’d like to display, x is the horizontal alignment (LEFT, CENTER, RIGHT) or position in pixels from the left-hand side of the screen and y is the starting point of the top-left of the text. For example, to start at the top-left of the display y would be zero. You can also display a string variable instead of text in inverted commas.

You can see all this in action with the following sketch – Example 50.2, which is demonstrated in the following video:

Furthremore, you can also specify the angle of display, which gives a simple way of displaying text on different slopes. Simply add the angle as an extra parameter at the end:

Arduino

1

myGLCD.print("Hello, world",20,20,angle);

Again, see the following sketch – Example 50.2a, and the results below:

Displaying Numbers

Although you can display numbers with the text functions explained previously, there are two functions specifically for displaying integers and floats.

You can see these functions in action with the following sketch – Example 50.3, with an example of the results below:

Displaying Graphics

There’s a few graphic functions that can be used to create required images. The first is:.

Arduino

1

myGLCD.fillScr(red,green,blue);

which is used the fill the screen with a certain colour. The next simply draws a pixel at a specified x,y location:

Arduino

1

myGLCD.drawPixel(x,y);

Remember that the top-left of the screen is 0,0. Moving on, to draw a single line, use:

Arduino

1

myGLCD.drawLine(x1,0,x2,239);

where the line starts at x1,y1 and finishes at x2,y2. Need a rectangle? Use:

Arduino

1

2

myGLCD.drawRect(x1,y2,x2,y2);// for open rectangles

myGLCD.fillRect(x1,y2,x2,y2);// for filled rectangles

where the top-left of the rectangle is x1,y1 and the bottom-right is x2, y2. You can also have rectangles with rounded corners, just use:

Arduino

1

2

myGLCD.drawRoundRect(x1,y2,x2,y2);// for open rectangles

myGLCD.fillRoundRect(x1,y2,x2,y2);// for filled rectangles

instead. And finally, circles – which are quite easy. Just use:

Arduino

1

2

myGLCD.drawCircle(x,y,r);// draws open circle

myGLCD.fillCircle(x,y,r);// draws a filled circle

where x,y are the coordinates for the centre of the circle, and r is the radius. For a quick demonstration of all the graphic functions mentioned so far, see Example 50.4 – and the following video:

Displaying bitmap images

If you already have an image in .gif, .jpg or .png format that’s less than 300 KB in size, this can be displayed on the LCD. To do so, the file needs to be converted to an array which is inserted into your sketch. Let’s work with a simple example to explain the process. Below is our example image:

Save the image of the puppy somewhere convenient, then visit this page. Select the downloaded file, and select the .c and Arduino radio buttons, then click “make file”. After a moment or two a new file will start downloading. When it arrives, open it with a text editor – you’ll see it contains a huge array and another #include statement – for example:

Past the #include statement and the array into your sketch above void setup(). After doing that, don’t be tempted to “autoformat” the sketch in the Arduino IDE. Now you can use the following function to display the bitmap on the LCD:

Arduino

1

myGLCD.drawBitmap(x,y,width,height,name,scale);

Where x and y are the top-left coordinates of the image, width and height are the … width and height of the image, and name is the name of the array. Scale is optional – you can double the size of the image with this parameter. For example a value of two will double the size, three triples it – etc. The function uses simple interpolation to enlarge the image, and can be a clever way of displaying larger images without using extra memory. Finally, you can also display the bitmap on an angle – using:

Arduino

1

myGLCD.drawBitmap(x,y,width,height,name,angle,cx,cy);

where angle is the angle of rotation and cx/cy are the coordinates for the rotational centre of the image.

The bitmap functions using the example image have been used in the following sketch – Example 50.5, with the results in the following video:

Unfortunately the camera doesn’t really do the screen justice, it looks much better with the naked eye.

What about the SD card socket and touch screen?

The SD socket didn’t work, and I won’t be working with the touch screen at this time.

Conclusion

So there you have it – an incredibly inexpensive and possibly useful LCD module. Thank you to Henning Karlsen for his useful library, and if you found it useful – send him a donation via his page.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.

Hi John,
that looks really good for its price, I am building a robot controller for outdoor use, and I had planned to use 2 lcd displays ( white on blue backlit background ) but testing it outdoors yesterday you could hardly see the writing.
This unit looks very bright, but of course its pictured indoors.
Do you think its brighter than a bog standard LCD?

Salut,
the UTFT library is absolutely worth a donation. Henning has written a superb peace of code. I use it with several TFT without issues and of course, I have done my donation (I suggest 5 Euro/TFT you use ;^)
Ciao! Mathias

Hi John:
Thanks so much for your article. First of all, a newbie, so please bear with me.
I am not using Arduino – using a PIC16F877 instead, but the exact display you are using!
I have not been able to find any documentation re the pinouts for the display except the ILI9325 Data Sheet. Unfortunately this does not give me a clue where the Backlight pin is on the display. I can’t figure out where the touchscreen x, y+ etc are or what PEN_Q, DOUT etc are used for!
Do you know where I can get some data on the actual display?
A search for “HY-TFT240_262k HEYAODZ110510” only comes up with your article!

Do you know if this works with an arduino nano v3. I have connected as per instructions above and downloaded the sketch with utft pins set to 24,23,22,21 but I do not get any text displayed , just backlit.

Hi, I figured out how to make the code smaller by un-commenting the defines for other chipsets , in the memorysaver.h file, now the program to claibrate the touch screen loads but there is no touch working. Does yours?

I didn’t RTFM. Forgot to connect the pins for the Utouch functions. “myTouch(6,5,4,3,2);”
But I’m having mixed results. The calibration example works and recognizes the stylus input. Then I copied the CAL_X, CAL_Y and CAL_S value to UTouchCD.h
After that the button example did not recognize anything. Also tried LANDSCAPE and PORTRAIT mode. When Serial.print X and Y values it does show values.

Very timely post, I was researching new and better LCD displays for my project and just happened to stop by here to see what was new and found your tutorial on the color displays. Ordered two (both worked), and grabbed the UTFT library. Henning was most helpful when I had download difficulties, but it all got sorted out.

Everyone, if you use this library, please consider sending Henning a donation, the UTFT library is excellent, well written, and well documented with many example sketches. It really does some amazing things.

Now awaiting the delivery of my new Mega2560, as I got so involved in writing code that my Duemilanove ran out of flash memory. 32k seemed like so much space such a short time ago…

Hey John,
Thank you for the post! Do you have any advice on moving the data pins? I’m trying to to grab a .bmp file from the Uno Wireless/SD shield but there is a conflict with pin 4 (needed for the SDCS).

Did anyone actually ever get the UTFT ibrary to work on a Mega2560? I have had absolutely no success attempting to run either the UTFT examples or the sketches presented here on a Mega. All I get is a white screen, in spite of wiring and re-wiring the LCD to the proper pins on the board.

I finally got the screen and the touch working with my UNO, I got the calibration data wrong at first, typos!
I’m thinking of doing a pcb for the display, which would be better, a shield for the UNO or a pcb containing its own smd 328p (extra IO)?

Nice work. If you were going to manufacture something, give it the option of being 5V/3.3V compatible so the Due can use it and also people with the little computer… I thinks it’s called a Raspberry Pi?

Hi, John!
Two month ago I changed display on my Samsung E1080 mobile phone and I’ve bought 3 spare displays for the mobile.
Now I have two absolutely new displays and I want to use them with Arduino.
Displays are marked on the top side as 4535A; on the back side as FPC4535A-V3-F
Displays dimention – 128х128 px.
Colors – 65535.
I asked Samsung for help but I was refused. No datasheet was found over internet. Can you give me advise how to use the displays?
Thank you!