MCUFRIEND using the uno shield on the mega, how to make it faster?

I have a 3.5 inch LCD ili9486 Uno shield that I have been using on the Uno, the speed is fine but I need more memory, so I want to use it on the Mega 2560 but its too slow.

I have been reading some forums and replies from David Prentice, in one of the older forums he said that the Mega will run more slowly as the Uno uses Hardware SPI and the Mega uses Software SPI.

the Pins I believe are

50 = PB3
51 = PB2
52 = PB1
53 = PB0

but I have no idea on how to set this or what pins would connect where (RD, WR, CD, CS, RESET).

on another note, I'm getting confused with SPI and Parallel, with SPI I thought it only used the pins mentioned above but I have to also connect the LCD_D0 - LCD_D7.

wouldn't that mean its parallel?

The TFT is parallel
The microSD card is SPI.

Quite honestly, most programs will fit in a Uno's Flash memory.
Obviously a Mega has got lots of spare GPIO pins.

A Mega works very fast with a Mcufriend Mega2560 Shield.
A Uno works reasonably fast with a Mcufriend Uno Shield
A Mega works SLOW with a Mcufriend Uno Shield.

All the same, a well designed program will probably never notice the slower speed.

Post your code. Or explain your speed problem.

There is nothing that I can do to speed up delivery of the appropriate Shield from China.
But I suspect there would be a few tips that readers could give you for improving the design of your code.


I tried to pick a display that would work for a simple game, as I wanted to build myself my own version of the Gameduo or similar but at the same time have extra ports for extras stuff.

to be honest, when you said “A Mega works very fast with a Mcufriend Mega2560 Shield”

that will do for me, I will just buy one of those.

however since I have the man that made all this possible, I might as well ask another question if that ok.

my code is just using one of the example codes, cleared most of it.

It has a make shift man drawn, by just drawing shapes (plus a square as a reference to the speed)

I’m moving the square object by drawing a blue line in front by one pixel and drawing a white line behind by one pixel, giving the impression of movement. that way I don’t have to clear the screen.

when it comes to the man, it’s more difficult, as the circle (for his head) has a curved line.

what would you suggest to be the best method, of moving a more complex object with multiple colours across the screen without producing flickering?

readpixel? and read a block of pixels and compare it?

[code]// UTFT_Demo_480x320
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web:
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
// This demo was made for modules with a screen resolution
// of 480x320 pixels.
// This program requires the UTFT library.

// GLUE class that implements the UTFT API
// replace UTFT include and constructor statements
// remove UTFT font declaration e.g. SmallFont

#include <UTFTGLUE.h>              //use GLUE class and constructor
UTFTGLUE myGLCD(0, A2, A1, A3, A4, A0); //all dummy args

// Declare which fonts we will be using
//extern uint8_t SmallFont[];      //GLUE defines as GFXFont ref

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Uno / 2009:
// -------------------
// Standard Arduino Uno/2009 shield            : <display model>,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield        : <display model>,A5,A4,A3,A2
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega      : <display model>,38,39,40,41
// Remember to change the model parameter to suit your display module!
//UTFT myGLCD(CTE32HR,38,39,40,41);

int X = 0;
int Y = 0;

int X1 = 240;
int Y1 = 160;

int X2 = 0;
int Y2 = 80;

int X3 = 0;
int Y3 = 120;

int X4 = 0;
int Y4 = 180;

int delaysquare = 0;
int delaysquare1 = 0;
int delaysquare2 = 0;

void setup()

  // Setup the LCD
  // myGLCD.setFont(SmallFont);
  myGLCD.fillScr(255, 255, 255);

  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRect(X, Y, 30, 30);

  myGLCD.setColor(255, 153, 153);
  myGLCD.fillRect(X1 - 17, Y1 - 15, X1 - 10, Y1 - 13);

  myGLCD.setColor(192, 192, 192);
  //myGLCD.fillRect(240, 144, 229, 148);
  myGLCD.fillRect(X1 - 11, Y1 - 16, X1, Y1 - 12);

  myGLCD.setColor(160, 160, 160);
  myGLCD.fillRect(X1 - 1, Y1 - 16, X1 + 5, Y1 + 16);

  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(X1, Y1, 8);


void loop()

  myGLCD.setColor(0, 0, 255);

  X ++;

  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRect(X, Y, X + 30, Y + 30);

  myGLCD.setColor(255, 255, 255);

  myGLCD.drawLine(X - 1, Y, X - 1, Y + 30);

  delay (0);
  if (X == 450) {
    myGLCD.setColor(255, 255, 255);
    myGLCD.fillRect(X, Y, X + 30, Y + 30);

    X = 0;
    myGLCD.setColor(0, 0, 255);
    myGLCD.fillRect(X, Y, 30, 30);

  //back of shoulders
  myGLCD.setColor(255, 255, 255);
  myGLCD.fillRect(X1 + 5, Y1 - 16, X1 + 8, Y1 + 16);

  myGLCD.drawLine(X1 + 5, Y1 - 16, X1 + 5, Y1 - 8);


  myGLCD.drawLine(X1 + 5, Y1 + 8, X1 + 5, Y1 + 16);

  myGLCD.setColor(255, 153, 153);
  myGLCD.fillRect(X1 - 17, Y1 - 15, X1 - 10, Y1 - 13);

  myGLCD.setColor(192, 192, 192);
  //myGLCD.fillRect(240, 144, 229, 148);
  myGLCD.fillRect(X1 - 11, Y1 - 16, X1, Y1 - 12);

  myGLCD.setColor(160, 160, 160);
  myGLCD.fillRect(X1 - 1, Y1 - 16, X1 + 5, Y1 - 8);

  myGLCD.setColor(160, 160, 160);
  myGLCD.fillRect(X1 - 1, Y1 + 8, X1 + 5, Y1 + 16);

  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(X1, Y1, 8);

  if (X1 == 0) {

    myGLCD.setColor(255, 255, 255);
    myGLCD.fillRect(X1 - 17, Y1 - 16, X1 + 8, Y1 + 16);

    X1 = 450;




OK, let's cut to the chase.

Please go and read the instructions, then go back and modify your post using the "More --> Modify" option you will find to the bottom right of the post, to mark up the code (but it always needs to be the complete code) as such so we can examine it conveniently and accurately. Please do not post a ".ino" file as an attachment - that would mean that you are expecting people to actually load it to their IDE to look at it and that is extra unnecessary labour. In fact, attachments do not always show properly on different operating systems.

Because you did not mark it up as code, the code you have posted is slightly garbled and is certainly anything but easy to read. One funny character is obvious but I didn't look too closely for others.

Note: Also mark up any data - as a separate section - in the same way. This includes error output that you get from the IDE.

And - before you post any code, use "Auto Format" in the Tools menu of the IDE to properly present the code. You can then use the "copy for forum" function in order to paste it into a message with the "code" tags already provided.

Try and avoid unnecessary white space (blank lines). You should only use these to separate functional blocks of code.

Thanks, Paul. I was going to suggest CODE window and auto-format.


Please write new programs with regular Adafruit_GFX methods. UTFTGLUE is only for old legacy UTFT programs.

I am not familiar with Game programs.
If you want help, post a link or video of the game that you want to emulate. It is easier than trying to describe in words.


Sometimes an 'ino' file is required as attachment as the forum postings have a character limit for messages.

This means a reasonable code block plus user meassage can exceed this.

Hi David.prentice

I'm now using the Adafruit_GFX library.

A bit annoying as some of the function have changed, like the colour select.

its now in hex and not the 255,255,255.


I have now ordered the same type of display (3.5inch ili9486) but a Mega shield using the pins 22 - 53 area.

I have just remembered seeing something in your code or an old tread, that said the mega shield uses different ports and so it is slower and that if you use pins in PORTF its much faster.

I guess the fact that the Mega shield should use the Hardware SPI pins (50-53) will make this faster.

can you clarify this please? :slight_smile:

sorry about the wrong format, I don't often use Forums and I was getting stressed trying to figure out the display, just the other day I was learning about PORTs.

Most Graphics code for an Arduino uses Adafruit_GFX methods. They are much more intuitive than the UTFT class methods.

Regarding Mega2560 shields. Some do not have Touch. Many do not work with the SD.

It is always WISE to post a link to the actual display that you have bought (or intend to buy)
Note that Ebay and Ali descriptions and pictures are often wrong. You must compare photos VERY carefully.