Go Down

Topic: 2.8" LCD TFT touch shield on mega (Read 227 times) previous topic - next topic


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.


Feb 25, 2018, 02:42 pm Last Edit: Feb 25, 2018, 02:43 pm by david_prentice
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.


Mar 04, 2018, 04:41 pm Last Edit: Mar 04, 2018, 04:47 pm by abby1010 Reason: picture was too big
I bought the shield from a webshop in the Netherlands, called "Hackerstore". I asked the people for more info, but they couldn't help me....??(they sell product without any support).

The shield was designed for the Uno but it was said and written that it  could  used for the Mega as well. It was only a matter of downloading the library UTFT, uncomment line 7 and that's it.....??? Well I did, but without result.

I hope You can help me, while it is very frustrating.

Please have a look at the attach pic.

Kind regards,



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?



Mar 04, 2018, 11:18 pm Last Edit: Mar 04, 2018, 11:19 pm by david_prentice
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.



YEH!!!!! IT'S WORKING!!!! great David, thanks.
I tried several examples and they worked with no problems at all. The pin assignments are also
in line with the Mega board, so no wiring at all.
Now I am going to figure out to get the alpha numerical txt horizontally only, (reverse) in de setup and  in the not in the loop.

Thanks again.



The display is working fine for now. Another thing I like to ask now is the following:

Once I have a standard text I want to display a variable in the next line. I don't like to refresh the whole page with "clearScreen(0x000); but just clear the appropriate line with the variable only.
What I did for now is overwriting all numbers in black and then go back to the origanal color and write the Val again. (bit stupid or not????)

Is there a standard expression (delete,erase,clear......) in the library or so??

thks in advance.




Mar 17, 2018, 11:38 am Last Edit: Mar 17, 2018, 11:38 am by david_prentice
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.



Thanks David,

I tried, but but got the following reply:

no matching function for call to 'MCUFRIEND_kbv::fillRect()'


The next error message I got was:

no matching function for call to 'MCUFRIEND_kbv::getTextBounds()'


fillRect() requires arguments.
from MCUFRIEND_kbv.h:
Code: [Select]

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

from Adafruit_GFX.h:
Code: [Select]

    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)


Go Up