Getting TFT touch display working with Mega 2560

I have been struggling to get my Mega 2560 ADK and LCD 2.8″ TFT TOUCH DISPLAY (from to work together and knew the problem must be with the pinouts that is different between the Uno and Mega boards. (I would suggest getting one of the Adafruit version of the TFT displays)

Using the UTFT library I just got stuck with a blank white screen and nothing else. Was also looking for exact board pinouts to comapre the pins on Uno and Mega and found this awesome pins layout.

First thing I did was to change the pins used in the main class constructor UTFT to the following:

UTFT myGLCD(ILI9325D_8,A5,A4,A3,A2);

Even though the A2 RST pin is not available on the TFT Display. Still no luck with just a white screen.

Then, I emailed Henning Karlsen the problem and very quickly received the following response:

“First of all, the 2.8” TFT Touch Shield is not fully supported by the
library due to the lack of the RST pin.

I do not think the big USB connector is a problem as long as all pins go
almost all the way down. Your biggest problem is that the shield was
made for use on a 2009/UNO sized Arduino. If you look at the
requirements for the library you will see that the required pins are
different when using a Mega-based Arduino.

To have any chance of getting this to work you have two options:
1. Use connector wires to connect the shield to the correct pins.
2. Modify the library to use the shield pins. Please see this
) How-To. Please understand that this modification impacts the speed
of the display operation by 30-40%.

Even if you do either of these options there are still the issue with
the missing RST pin which may cause unforeseen problems.”

via Electronics – Henning Karlsen:

“How-To: Modifying UTFT to accept Arduino shields on an Arduino Mega

I have been getting a lot of emails asking why UTFT doesn’t work when using a shield made for an Arduino 2009 or Uno on an Arduino Mega. I will try to explain why here and also show you how to make it work.

To understand this how-to you should have a basic understanding of Bitwise logic and Bitwise operations in C. You should also have a basic understanding of how direct access to the ATmega ports work.

This How-To will only explain how to use 8bit display modules and shields on an Arduino Mega, but if you follow through you should be able to figure out the remaining bit for 16bit modules yourself.”

So I used the easy way and this produced the following “HW_AVR.h” file:


Download, UnZip, Copy and replace this HW_AVR.h file into your UTFT folder, re-compile and upload your examples and now it should work. Not sure when I will run into problems with the RST pin, but will post an update if I do.

11 thoughts on “Getting TFT touch display working with Mega 2560

  1. Thanks for making this post !
    I had the same problem , i thought i broke it ….
    but by following your link and replacing the “UTFT myGLCD(ILI9325D_8,A5,A4,A3,A2);”
    i fixed it =) , now getting it to run on my arm cortex m3 :C

  2. Pingback: Henning Karlsen UTFT Library update |

  3. I’ve been using version 4.2 of ITDB02_Graph and tried moving to UTFT on my Uno. I get the blank screen when trying to use UTFT where I’ve had no problems using ITDB02_Graph. I tried downloading the Above HW_AVR.h file and did the recompiling and uploading but still getting the blank screen. Not sure what else I need to do. Any help appreciated.

    • I seem to be facing the same issue, could you please clarify how we supply the controller chip info?
      Is it by defining __AVR_ATmega2560__ in our application?

  4. Hey.. thanks for the help..
    but you forgot to add “UTFT::” in the line 159 in function void _set_direction_registers(byte mode)

    rest worked like a charm.. Thanks..

    (Tested on Arduino Mega ADK)

    • i faec the same issue with an arduino mega ADK and 2.4″TFT LCD Shield, I downloaded HW_AVR.h file and added the missing “UTFT::” and did the recompiling and uploading but still getting the blank screen.
      please help !!!!

  5. Hi Jacques,

    Hope you can help me here. I recently purchased this Arduino MEGA ADK (Rev 3) , 2.4″ TFT (240*320) Touch LCD and the TFT LCD Mega Shield V2.2 by Elecfreacks. I´m trying to get this this working nothing fancy just one of the Demos (UTFT_ViewFint) that came in the UTFT files from Henning Karlsen. What Iím doing is open a new sketch and paste the demo file after that I juts compile it and after that i got this big list of errors :

    In file included from UTFT_Textrotation_Demo.pde:12:
    C:\Archivos de programa\Arduino\libraries\TFT/UTFT.h:157:42: error: hardware/avr/HW_AVR_defines.h: No such file or directory
    In file included from UTFT_Textrotation_Demo.pde:12:
    C:\Archivos de programa\Arduino\libraries\TFT/UTFT.h:206: error: ‘bitmapdatatype’ has not been declared
    C:\Archivos de programa\Arduino\libraries\TFT/UTFT.h:207: error: ‘bitmapdatatype’ has not been declared
    C:\Archivos de programa\Arduino\libraries\TFT/UTFT.h:226: error: ISO C++ forbids declaration of ‘regtype’ with no type
    C:\Archivos de programa\Arduino\libraries\TFT/UTFT.h:226: error: expected ‘;’ before ‘*’ token
    C:\Archivos de programa\Arduino\libraries\TFT/UTFT.h:227: error: ‘regsize’ does not name a type

    Thanks in advanced.


  6. Hy all , Is somebody reach to works with ILI9341 shield from SeedStudio ( TFT V2.0 ) , I Would like to work with this kind of Library but at this time I cannot , I tried many configuration but haven’t got all the Information I need to make this LCD working .
    Feel Free to give me some intresting link where I can find Pinout Diagram ( All Pins , not only the one showed on seed web site , if someone have this information , to try to adapt the constructor configuration in a sketch .
    Thx a lot in advance .

Leave a Reply

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