Introduction: How to Use 2.4 Inch TFT LCD SPFD5408 With Arduino Uno and Mega

Picture of How to Use 2.4 Inch TFT LCD SPFD5408 With Arduino Uno and Mega

This Instructable is to know how to work TFT 2.4 with the controller SPFD5408
with the libraries of Adafruit for TFT.

This library is the Adafruit TFT Libraries changed to works in TFT 2.4 shields with the SPFD5408 controller.

Now it is for Uno and Mega, Teensy is on the way...

It is based in the last version of Adafruit, inclusive with buttons features.

The TFT 2.4 is cheap TFT, that generally is from China, without documentation or libraries for it.

I tested some mcufriend shields.

When we try to use the TFT 2.4 with SPFD5408 controller in sketches with Adafruit TFT libraries, several things can happen :

  • White Screen
  • All screen with noise
  • Touch not works or is inverted (coordinate Y)
  • The colors are inverted
  • And other things

After trying for several days trying the solutions I found on the web, and none works 100%. So I decided to do an library specific to this controller.

I changed the Adafruit libraries for TFT: GFX , TFTLCD and TouchScreen. I join all in this one library, the library SPFD5408, to avoid problems with duplicate libraries and enables also have the original library Adafruit ready for use in other projects with another TFT hardware.

Step 1: Download the SPFD5408 Library

Picture of Download the SPFD5408 Library

I made available it in my GitHub .

Please download it in:

Attention: This library is ONLY for SPFD5408 TFT controller

If it not work, and you get a blank screen,

please access this site to help you identify the correct library:

Step 2: Install

Picture of Install

Please follow the details in README.

Step 3: First Test - Graphicstest

Picture of First Test - Graphicstest

I modified the Adafruit graphicstest to work.

Please open the folder in spfd5408_graphicstest sketch example.

Upload this to Arduino Uno

Step 4: Test 2 - Tftpaint

Picture of Test 2 - Tftpaint

TftPaint is a sketch from Adafruit_TFTLCD, is a one simple paint, but important for learning and test the TFT.

I modified this to work.

Please open the folder in spfd5408_tftpaint sketch example

Step 5: Utility - Calibrate

Picture of Utility - Calibrate

This TFT is with a resistive touch, and need calibration for accurate the touch

I made one sketch to help this process.

Please open the folder in spfd5408_calibration sketch example.
After the run of this program , you have the parameters of calibration to put in your sketch code.


PrinceCharles23 made it! (author)2017-11-21

well i am out of ideas. i tried to find out what board i have (using

i tried several different libraries. (it feels as if a have tried all of the suggested lib even though they are intended for some other chip).

some of them do not work at all. some of them do not detect the chip correctly and can be helped to work by explicitly setting the chip identifier to 0x9341 (in my case) by calling tft.begin(0x9341).

but the best result i can get is a split screen with doubled output.

any ideas, any solutions?

wiredcav (author)2017-10-23

This instructable and your library have been extremely useful. Thanks so much. I've got it all working, but now when I write a new sketch I'm finding I'm having trouble with waitOneTouch(). It appears that several "touches" are being buffered. I notice in the Adafruit_STMPE610 there is a bufferEmpty() function that lets me check the buffer and keep reading until it's empty. But I can't find such a function in the SPFD5408 lib. Any tips would be greatly appreciated. Thanks!

wiredcav (author)wiredcav2017-10-24

In case this might be helpful to others, I've got this worked out to my satisfaction. I don't quite understand why it works, but if you add a short delay between calls to waitOneTouch() it seems to work normally.

AlbertS92 (author)2017-10-09

Your examples are excellent working!! Thank You very much.

Akshay KG (author)2017-09-17

Thank you sir, finally i got a right library for it! while i run the "paint" example, i had noticed that the touch plate is not working properly, if i touch at the right corner it is selecting the left corner; how can i fix it?

PeterGB66 (author)Akshay KG2017-10-02

Thanks to slava_gll, I tried his tip for editing SPFD5408_TouchScreen.cpp, and for the first time after quite some nights of struggling the touchscreen is working in the correct x-y directions!

So, in SPFD5408_TouchScreen.cpp, change lines 157-164 to:

return TSPoint(y, x, z);

// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
//return TSPoint(x, 1023 - y, z);
// -- End

NOTE: y and x reversed!

aprada66 (author)2016-06-25

I tested all examples, and I have duplicated images in all testings.

JoaoLopesF (author)aprada662016-06-26

Hi, I think the controller not is SPFD5408.

Please try the web site to help you identify the correct controller/library:



Hello, I have the same problem, sketch confirms to me that the driver is sdfp5408. The image is duplicated. any advice?

Orlando AntonioM made it! (author)Orlando AntonioM2016-10-14

please help me!

Hi! I've the same problem and after a big number of test I've finally discover the correct driver for my lcd.

Take a look to the link:

My LCD has an identifier of 0x1520 that isn't not in the other sketch that I've tried.

مهیارن1 (author)MarioP1102017-09-30


My little sister has same problem, but my ID is not even 0x1520.

What do you suggest about it ?


JoaoLopesF (author)aprada662016-10-14

Hi, I dont see it before...
Do you see ID in the site misc.wc ?



ShrutiS27 (author)2017-09-24

Thank you so much for the post. But I still can't fix the mirrored text and also it occupies only partial screen :/ Can someone help? The below comments din't help :/

Ram Warutkar (author)2017-09-23

Thanks man

rich1812 (author)2017-08-04

HI, I have quite a few of these screens for the Arduino aleard. I like it. Now I have a Raspberry Pi, I do really want to buy yet another one just for Pi. Can I convert it to uae on Pi? I think it is a matter or usung the Pi GPIO, or configure Uthe GPIOs to mimic the Adruino, can this be done? Thanks,

MostafaV (author)2017-07-18


My touch screen does not work at all. Do you know whats wrong here?

bruhnstv (author)2017-05-16

Thanks much, Joao! I was dreading getting started trying to make these little displays work, with no documentation and the word on the street being that even displays that looked alike might have different controllers. There were several Arduino libraries to pick from, but yours looked relatively straightforward and I liked your Instructables writeup. The libraries and the graphics test sketch worked, kind-of, with same problems as padouet reported, but it was fairly easy to find fixes for those, and now the graphics test sketch is working correctly. (Fixes noted below...)

padouet (author)2017-04-23

Hello JoaoLopesF

Thank you for your work and librairies.
With my first tft 2.4 touch screen, it is very good, it is 0x9341 or ili9341..

Now, with my new 2.4 touch screen,I have a big problem., it is 0x9342 or ili9342 and your librairies give a bad result. All other librairies give nothing.

- colors are inverted ;black is 0xffff and white is 0x0000
- texte is mirored
- picture is troncated : landscape <=> paysage

On this no mine video, at 8'15" you can see what I have on screen

The ILI9341 and ILI9342 are very
similar but the latter is configured for 320x240 (960 x 240 outputs)
instead of 240x320 (720 x 320 outputs).

Here data for ili9342

Please, can you release your librairies ?
Thank you very much.

bruhnstv (author)padouet2017-05-16

Hello padouet,

I had EXACTLY the same problem this evening when I first started. I fixed each problem with some code changes:

First, the colors. I just swapped the color definitions in the test sketch. There may be a better way, but this works. Swap white and black; swap blue and yellow; swap red and cyan; swap green and magenta. (I need to dig into this a little further. The datasheet for the ILI9341 clearly shows 6 bits per color, but in the sketch, only 16 bits are used to define the colors... Also, it may be possible to send some bit(s) to the ILI9341/2 to invert the colors. I only started to look at the data sheet maybe two hours ago, so there is a lot in it I have not investigated.)

Second, for the reversed text: in SPFD5408_Adafruit_TFTLCD.cpp, look for lines with ILI9341_MADCTL_MX. You should find only two such lines, in case 1 and case 2 of the section that deals with rotation. Remove that part (and the following | ) from those two cases and add it to case 0 and case 3. This swaps the "X" direction for each rotation. (The definition of ILI9341_MADCTL_MX is in registers.h; it's just the bit position of MX in the ILI9341 memory address control register.)

Third, for the portrait <-> landscape problem, I just swapped the sizes in the #defines for TFTWIDTH and TFTHEIGHT. It occurs to me that I might have been able to do it differently; I suppose it could depend on what you want to think of as the width and the height of the display: are you using it in portrait or in landscape orientation. But anyway, that worked for me. It's late; I'll try playing with the other tests tomorrow!

GianlucaB25 (author)2017-05-02

Hi! This is the first library that seems at least to partially work with my TFT. But I can't get the touch to work properly: in the calibration sketch I can manage to get to the second screen (after A LOT of touches) but then it doesn't respond at all. Any suggestions?

Blun7 (author)2017-04-30

two comments:

1) WHERE do you measure the X resistance for the touchscreen (where do I place the probes of the multimeter)?

2) have thus working on an arduino mega board, but want to use it on a custom board with an AVR atmega128A (64 pin MCU). What physical pins do I use?

宇承張 (author)2017-04-07

How to display Chinese characters in 24 inch tft lcd ?

jainrk (author)2017-03-06

JoaoLopesF, Thanks for work on this fork. I spent numerous hours trying to figure out to get it to work, until I found your library on GIT hub. Now it all works.

rupamr2 made it! (author)2017-02-08

You saved my life. Can't say thanks enough!

Just added Vcc, Gnd, Tx, and Rx and Made it a quick debugging display. It reads from serial data, formats and prints it on display. Thanks.

Biber_null (author)rupamr22017-03-04

hi @rupamr2, share your code will you?

theworldowner. (author)2017-02-19


KyleGass (author)2017-02-12

I have the same Problem.

With arduino uno r3. I tried it with the arduino ide 1.0.6 & 1.8.1. I use the same display (2.4 TFT SPFD5408) as you and the "SPFD5408 Library 0.9.2". I tried to start any example but there is only a white screen. Do anyone have an idea how to fix it?

abhijit2683 (author)2017-01-07

Hi Joao,

When I am using this library, I am getting white screen. Could you please guide me how I will able to solve this problem?

RajarshiK2 (author)abhijit26832017-02-09

Abhijit try here....

feddar (author)2016-09-16

I got one of these shields from China. I tried your library and sketch, but I get a white screen. On serial monitor, it looks like the tests are working (in graphicstest). Any idea what I should do?

RajarshiK2 (author)feddar2017-02-09

Pls try here

abhijit2683 (author)feddar2017-01-07

Hi Feddar,

I am facing the same problem. Can you please guide me how you solved this problem?

feddar (author)abhijit26832017-01-08

i followed the link below and tried a few. Never got it fully working, though. Oh well, a wasted $7...

JoaoLopesF (author)feddar2016-10-05


This library is only for SPFD5408 controller,

please try the web site to help you identify the correct controller/library:



feddar (author)JoaoLopesF2016-10-06


RajarshiK2 (author)2017-02-09

For those who are recently purchasing the Chinese ones....and the display remains white .........even on trying out the methods described may try and use the library files available here.......

Mine started working!!!

Thank you any ways....

leakbarax made it! (author)2017-01-16

Thanks a lot, finally done. I spent a night to try several library for this shields, before found very usefull information in this instruction.

ZackH5 (author)2016-12-15

Hi JoaoLopesF,

Can it work with 2.8 inch TFT LCD ILI9341 controller?

hbaker6 (author)2016-12-12

Hey there

I bought a near identical TFT shield on ebay (mcufriend) and it came with NO documentation and I cannot read Chinese characters.

Your corrected libraries are the only ones that have managed to work for me and this setup. so I wanted to thank you for that.

The problem I'm having is that the input from the touch screen is inverted to what is shown on the screen. For example if I drag my finger down the long way of the screen the line is displayed going across the short way of the screen and vice versa.

I attempted the fix you sent to slava_gll but it did not work. I am novice level and played around with some of the code(exchanging every X and Y i could find, and switching them back after they didnt work) but nothing I tried worked. Any idea what is causing this and any help to point me in the right direction would be greatly appriciated, Thanks!

VictorZ24 (author)2016-12-04


There are 5 tiny buil in buttons at the edge of the LCD. Do you know how to read them ?

Thx, VZ

slava_gll (author)2016-11-11

mine screen is ok, but my touch not.

it's flipped 180 degrees

pls help

JoaoLopesF (author)slava_gll2016-11-12


please edit SPFD5408_TouchScreen.cpp,

and change the line 157-164 to:

return TSPoint(x, y, z);

// *** SPFD5408 change -- Begin
// SPFD5408 change, because Y coordinate is inverted in this controller
//return TSPoint(x, 1023 - y, z);
// -- End


Some TFT need this invertion



slava_gll (author)JoaoLopesF2016-11-12

//return TSPoint(x, y, z);

// *** SPFD5408 change -- Begin

// SPFD5408 change, because Y coordinate is inverted in this controller

return TSPoint(y,x, z);

// -- End

that helped

slava_gll (author)JoaoLopesF2016-11-12

Thank you very much

StevenM8 (author)2016-11-08

I am really new at this. The screen works great with your help, but the touch doesn't work at all. Any tips?

StevenM8 (author)StevenM82016-11-08

Actually, it seems to register a touch on the initial calibration screen, but then it shows the dot stuck in the top left corner with no way to touch it. I went in and tried to move the dot and it is always in the top left corner no matter what I set "tft.setCursor()" to.

pkmonster (author)2016-10-31

Can I port your library to Energia platform? Do you have any experience with that?

I really want to use the LCD TFT with my launchpad Stellaris Tiva C11294 XML.

Your library works very well with my Arduino Uno :P

Hope to see your response soon. Thank you so much

Gerardb23 (author)2016-10-12

Hi Joao...

I have a problem...myTFTLCD, has 183.000ohms (183K) between X+ y X-, and then is not posible work it how tactil screen, i buy 2 TFTLCD on different store (isn`t mcufriend) and the value of resistance is self.

I work on it a lot of days, but I can do that....

Thank for your help....

WirttiP (author)2016-10-12

Nice job! Thanks for sharing!

About This Instructable




More by JoaoLopesF:Remote Debug for Arduino ESP8266 Over TelnetHow to use 2.4 inch TFT LCD SPFD5408 with Arduino Uno and Mega
Add instructable to: