2.8" LCD TFT touch shield on mega

I have an Arduino Mega wih a 2.8" LCD TFT touch shield and want to use the the shield in the serial mode. The touch option is not relevant for me while i am not gana use it. Can anaone help me with the wiring, the lib. and may some exampel ide?? thks in advance.

You have more hair than me. Is it dyed?

Post a link to the actual display that you have bought. e.g. Ebay sale.


If the tft screen is really a shield designed for your Mega, then the wiring is the least of your problems. It simply plugs in. Anyway, post a link as requested and much should be revealed. There’s a huge variety of similar looking screens out there with different, controllers, pin configurations, voltage tolerance, internal wiring, register settings, addresses etc. etc. Like snowflakes, no two are ever the same.

I have made numerous attempts to upload your JPEG. My PC is not happy.

Can you provide a link to the sale website or any website with an accurate photo of the pcb?


My apologies. It looks like PC has a problem with TWINUI. IrfanView displayed fine.

You have a "Blue 2.8 inch Mcufriend Uno Shield".

Install MCUFRIEND_kbv via the Library Manager. It should work on the Mega.


There are two ways to overwrite text with a GFX style library:

  1. default System 7x5 font. Use tft.setTextColor(foregroundcolor, backgroundcolor);
  2. Call tft.getTextBounds() to get the size of previous text. Use tft.fillRect() to rub it out with backgroundcolor.

  3. Call tft.print() to draw the fresh text.

With the FreeFonts fonts you must always use (2) In practice, clearing a whole line is very fast with fillRect()

If your program "refreshes" a variable in several places it is worth writing a helper function that sets the cursor, fills the background, prints the variable.


fillRect() requires arguments. from MCUFRIEND_kbv.h:

 virtual void     fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);

from Adafruit_GFX.h:

    void getTextBounds(char *string, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);

You can see how to use GFX methods by GFX tutorial

Or just look at examples. But the easiest way is to use the 7x5 font with setTextColor(foreground, background)


Sorry, I make assumptions that a User can understand a formal function or class method declaration.

C is a lot easier to follow than C++. But I did show you a link to a GFX tutorial. And most Dutch citizens have an excellent command of the English language.

Please attach your complete sketch or paste it to your message in CODE window.

If you want to draw a YELLOW filled rectangle with width = 40 pixels, height = 20 pixels at coordinates (100, 150) you would say:

    tft.fillRect(100, 150, 40, 20, YELLOW);

The tutorial explains each graphical shape e.g. line, rectangle, circle, ... And the graphictest_kbv example shows each graphical method.

In practice, the easiest way to print a variable is:

    tft.setTextColor(CYAN, BLACK);  //CYAN foreground, BLACK background
    tft.setCursor(100, 150);   //where to print
    tft.print(variable);   //print the value
    tft.print(" ");   //followed by a space to rub out any previous digit

Normally you know how much screen to use for your variable. e.g. six characters for "123.45" So you can add your own padding spaces or use sprintf() to do the formatting.

And yes, sprintf() takes many different arguments. An empty list would be an error.

I would guess that there will be many Dutch language programming textbooks. And probably Dutch language Arduino tutorials.


You can ask as many questions as you want. Just provide the necessary information e.g. hardware links, library versions, ...


Hi There
I wouldn’t to produce a new topic with almost the same questions. Actually not the same but i mean that with the help of this topic i found a solve with my problem (connection TFT shield 2,8’ to MEGA2560). This display working properly with library “MCUFRIEND_kbv”. But hi have CD card on board and i’d like involve this card as well. Anyone know how is possibly?
For UNO with next library everything was good … but when i replaced UTFT.h to UTFTGLUE.h … i’m getting error.
That is accordingly correct, because UTFT doesn’t have function UTFT_SdRaw Files_onCard(UTFTGLUE);
Look at the bottom line…

#include <SdFat.h>
#include <UTFT.h>
#include <UTFT_SdRaw.h>
#include <TouchScreen.h>

blah blah blah (some code here)


blah blah blah (some code here)

UTFT_SdRaw Files_onCard(&TFT_DISPL);

UTFTGLUE does not support every UTFT method. It certainly does NOT support UTFT_SdRaw Files_onCard()

It is quite effective for building the UTFT examples. Please do not use on new programs.

If you have a MCUFRIEND style display, I suggest that you try all the MCUFRIEND_kbv examples. The microSD card on your display should work ok on a Mega2560. Follow the instructions in the showBMP_not_Uno example.

Note that Uno shields work best on a Uno. Probably slow on a Mega. And Mega shields only work on a Mega. They have too many pins for a Uno.


Thanks for answer but sorry for my programming knowledge. I found a “showBMP_not_Uno.ino” but during compilation i’ve got a error at this line

SdFatSoftSpi<12, 11, 13> SD; //Bit-Bang on the Shield pins

Error = SdFatSoftSpi’ does not name a type

You must read the instructions at the top of the sketch.

Copy-paste into Google Translate for your own language.

Ask if you do not understand.


I seen this (i mean instruction in sketch) and fixed that row :



Also i found in the SdFat.h this class SdFatSoftSpi


...... ......

Also i changed a library to last version SdFat-1.0.16.zip

anywhere - result of compilation = 'SdFatSoftSpi' does not name a type

What am I doing wrong???


I advise you to use the Library Manager.

Installing from ZIP does not work as well.

Leave IDE. Delete all "badly installed" versions of the SdFat library. Start IDE. Install properly with the Library Manager. Edit the config file.

When you use the Library Manager you can upgrade versions, ... from within the IDE. Yes, the current version is probably newer than in my instructions. Remember to edit the config file if you install a new version.


Oups... Shit... :((( After global searching on my computer i founded a lot of fat_s in different places. Even in AVR studio and so on... Now i will everytime us only Library Manager. No any zip.... Thanks a lot David. Now everything good. :))