3.5 inch tft lcd shield

I bought this display Treedix 3.5 inch TFT LCD Display 320 x 480 Color Screen Module Compatible with Arduino UNO R3 Mega2560 https://a.co/d/1tQXCfq

It says that it is a ILI9486 driver but I can’t get to use the MCUFRIEND library and display any examples on the display. I do not know what I al doing wrong, I tried changing parameters on the code for the 480x320 but it still dors not work. I connected the display to an Arduino Leonardo.

I would suggest you start with some simpler projects to so to say get your feet wet! Your link to azon does not help much. Change the post to something that shows technical information for this and any other hardware items you may have connected. Alsos post a schematic as you have it wired, not a frizzy picture.

Thanks for posting the link. Please compare all of the pictures in the link with the item on your desk.
Especially pic #2 which shows the blue pcb.

If the pictures match the item that you bought, everything should work.
i.e. plug Shield into the Leonardo as Nature intended. Run the examples.

Unfortunately "graphictest_kbv.ino" is too big for a Leonardo. But the others should be ok.

Re-install library via IDE Library Manager.
Don't change anything.
Quote example by name e.g. "diagnose_TFT_support.ino"
Copy-Paste any text from the Serial Terminal.

David.

1 Like

The OP has done everything correctly:

  1. posted a link to his display
  2. we know what an Arduino Leonardo is.
  3. The display is a Shield. so only requires plugging the Shield pins into the female sockets of the Leonardo.

If we want or need a schematic we will ask for it.

David.

Thank you,

I tried comparing the picture with the board I have on my desk but I cannot see well the J3 ports. Also, there are U2 and U3 on the picture and my board has U1 and U2 instead, I am not sure if there is a difference.

These are the pins that are connected and how I configured them to the Leonardo
LCD_RD A0
LCD_WR A1
LCD_RS A2
LCD_CS A3
LCD_RST A4
F_CS A5
I do not see an F_CS port on the picture of the link.

I do not know if I am doing something wrong.

What can you recommend for me to start or learn more to understand the code and terminologies of the Arduino and displays? Or at least make any examples from the library appear on the screen

When I say compare pictures. If the same components are in the same place, that is good enough !!
Yes, sometimes the copper traces are slightly different (if you have eagle eyes)
i.e. they should begin and end at the same places but might bend differently.

The most important thing is : plug the Shield into the Leonardo.
Never use trailing wires.

There is no footprint for a Flash Memory chip. So the F_CS is a mistake.
And those pcb with an empty SOIC-8 footprint are no good with a 5V Arduino. (Flash chips do not like 5V)

You don't configure anything. You plug the Shield and go.

David.

Moroever, I plug in the shield with the corresponding PCB, for example, reset with reset, 3.3V with 3.3V, and so on?

I did that and used the Glue_Demo_480x230 and gave an error of sketch too big.

This is the code
// UTFT_Demo_480x320
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// 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 : ,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield : ,A5,A4,A3,A2
//
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield : ,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega : ,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
//UTFT myGLCD(CTE32HR,38,39,40,41);

void setup()
{
randomSeed(analogRead(0));

// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}

void loop()
{
int buf[478];
int x, x2;
int y, y2;
int r;

// Clear the screen and draw the frame
myGLCD.clrScr();

myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(0, 0, 479, 13);
myGLCD.setColor(64, 64, 64);
myGLCD.fillRect(0, 306, 479, 319);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1);
myGLCD.setBackColor(64, 64, 64);
myGLCD.setColor(255,255,0);
myGLCD.print("http://www.RinkyDinkElectronics.com/", CENTER, 307);

myGLCD.setColor(0, 0, 255);
myGLCD.drawRect(0, 14, 479, 305);

// Draw crosshairs
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(239, 15, 239, 304);
myGLCD.drawLine(1, 159, 478, 159);
for (int i=9; i<470; i+=10)
myGLCD.drawLine(i, 157, i, 161);
for (int i=19; i<220; i+=10)
myGLCD.drawLine(237, i, 241, i);

// Draw sin-, cos- and tan-lines
myGLCD.setColor(0,255,255);
myGLCD.print("Sin", 5, 15);
for (int i=1; i<478; i++)
{
myGLCD.drawPixel(i,159+(sin(((i*1.13)*3.14)/180)*95));
}

myGLCD.setColor(255,0,0);
myGLCD.print("Cos", 5, 27);
for (int i=1; i<478; i++)
{
myGLCD.drawPixel(i,159+(cos(((i*1.13)*3.14)/180)*95));
}

myGLCD.setColor(255,255,0);
myGLCD.print("Tan", 5, 39);
for (int i=1; i<478; i++)
{
myGLCD.drawPixel(i,159+(tan(((i*1.13)*3.14)/180)));
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(239, 15, 239, 304);
myGLCD.drawLine(1, 159, 478, 159);

// Draw a moving sinewave
x=1;
for (int i=1; i<(47815); i++)
{
x++;
if (x==479)
x=1;
if (i>479)
{
if ((x==239)||(buf[x-1]==159))
myGLCD.setColor(0,0,255);
else
myGLCD.setColor(0,0,0);
myGLCD.drawPixel(x,buf[x-1]);
}
myGLCD.setColor(0,255,255);
y=159+(sin(((i
0.7)3.14)/180)(90-(i / 100)));
myGLCD.drawPixel(x,y);
buf[x-1]=y;
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

// Draw some filled rectangles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillRect(150+(i20), 70+(i20), 210+(i20), 130+(i20));
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

// Draw some filled, rounded rectangles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillRoundRect(270-(i20), 70+(i20), 330-(i20), 130+(i20));
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

// Draw some filled circles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillCircle(180+(i20),100+(i20), 30);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

// Draw some lines in a pattern
myGLCD.setColor (255,0,0);
for (int i=15; i<304; i+=5)
{
myGLCD.drawLine(1, i, (i1.6)-10, 304);
}
myGLCD.setColor (255,0,0);
for (int i=304; i>15; i-=5)
{
myGLCD.drawLine(478, i, (i
1.6)-11, 15);
}
myGLCD.setColor (0,255,255);
for (int i=304; i>15; i-=5)
{
myGLCD.drawLine(1, i, 491-(i1.6), 15);
}
myGLCD.setColor (0,255,255);
for (int i=15; i<304; i+=5)
{
myGLCD.drawLine(478, i, 490-(i
1.6), 304);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

// Draw some random circles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=32+random(416);
y=45+random(226);
r=random(30);
myGLCD.drawCircle(x, y, r);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

// Draw some random rectangles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(476);
y=16+random(289);
x2=2+random(476);
y2=16+random(289);
myGLCD.drawRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

// Draw some random rounded rectangles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(476);
y=16+random(289);
x2=2+random(476);
y2=16+random(289);
myGLCD.drawRoundRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(476);
y=16+random(289);
x2=2+random(476);
y2=16+random(289);
myGLCD.drawLine(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,478,304);

for (int i=0; i<10000; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
myGLCD.drawPixel(2+random(476), 16+random(289));
}

delay(2000);

myGLCD.fillScr(0, 0, 255);
myGLCD.setColor(255, 0, 0);
myGLCD.fillRoundRect(160, 70, 319, 169);

myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("That's it!", CENTER, 93);
myGLCD.print("Restarting in a", CENTER, 119);
myGLCD.print("few seconds...", CENTER, 132);

myGLCD.setColor(0, 255, 0);
myGLCD.setBackColor(0, 0, 255);
myGLCD.print("Runtime: (msecs)", CENTER, 290);
myGLCD.printNumI(millis(), CENTER, 305);

delay (10000);
}

I was telling lies !!

Many Most of the examples are too big for the Leonardo. these are ok:

aspect.ino
diagnose_TFT_support.ino
graphictest_slim.ino
readpixel_kbv.ino
scroll.ino
testcard_kbv.ino

LCD_ID_readreg.ino (is a digitalRead() / digitalWrite() text sketch )

even the TouchScreen_Calibr_native.ino is too big.
I can give you a "likely" calibration for Touch examples.

My apologies. I make sure that examples run on a Uno. After all, the Shields are intended for Uno.
I have tested the "above" examples on a Leonardo.

Your Shield should plug into the Leonardo looking like picture #6 in your Amazon link. i.e. the screen showing magenta circles.

Once you get the Shield working on the Leo you should be ok for small sketches. The Leo will always be SLOW. (because the data bus pins are on random GPIO ports)

A Due clone should be a better bet than the Leo.

David.

Thank you,

I tried the examples above and it takes a long time to upload.

Will it be recommendable to just get an Arduino Uno or Mega for faster upload and bigger sketches? Since, everytime I tried the examples that you mentioned it stays on the "Uploading"

This in an example of what it appears on the screen

I though I needed to change the analog pins according to the ones that are plugged in since there is no LCD_CD but I do have an LCD_RS

For faster and bigger sketches which Arduino board should I get? DUE, MEGA, or UNO?

I tried the examples suggested:
aspect.ino
diagnose_TFT_support.ino
graphictest_slim.ino
readpixel_kbv.ino
scroll.ino
testcard_kbv.ino

But nothing appears on the shield and this is what it says on the Arduino IDE/code

If you can't plug a Shield into a Leo I don't think that I can really help.

If you can't quote which example by name or copy-paste a Serial Terminal, I don't think anyone can help.

Uno Shields are intended for a Uno. They work pretty well.
The Uno Shield will work on Due at a reasonable speed. Leo and Mega are both going to be SLOW.

David.

I plugged the shield into the Leo like recommended in picture #6 of the amazon link. I tried the recommended examples mentioned above:
aspect.ino
diagnose_TFT_support.ino
graphictest_slim.ino
readpixel_kbv.ino
scroll.ino
testcard_kbv.ino

but the code does not uploads completely, it stays on "uploading" and the screen is just white.
This is an example of one of the examples recommended the code cor readpixel_kbv.ino:
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

//#include <Adafruit_TFTLCD.h> // Hardware-specific library
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
//Adafruit_TFTLCD tft;

// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

void setup(void);
void loop(void);

uint16_t g_identifier;

void setup(void) {
tft.reset();
g_identifier = tft.readID();

Serial.begin(9600);
Serial.print("readID = 0x");
Serial.println(g_identifier, HEX);
if (g_identifier == 0xFFFF) g_identifier = 0x9341;
if (g_identifier == 0) {
    Serial.println("Unknown ID");
    while (1);
}

tft.begin(g_identifier);
tft.setRotation(0);

}

uint16_t colors[] = {
BLACK, BLUE
};

void colordump(uint16_t x, uint16_t y)
{
uint16_t pixel, pixels[32];
char i, j, buf[20], dirty;
uint8_t wid = (tft.width() - 9 * 6)/ (5 * 6), ht = (tft.height() / 8) - 1;
tft.setTextColor(WHITE);
tft.setTextSize(1);
for (j = 0; j < ht; j++) {
sprintf(buf, "%3d,%3d:", x, y + j);
tft.print(buf);
dirty = 1;
for (i = 0; i < wid; i++) {
#if 1 && defined(MCUFRIEND_KBV_H_)
if (dirty) tft.readGRAM(x, y + j, pixels, wid, 1);
dirty = 0;
pixel = pixels[i];
#else
pixel = tft.readPixel(x + i, y + j);
#endif
tft.print(" ");
if (pixel == WHITE) tft.setTextColor(GREEN);
sprintf(buf, "%04X", pixel);
tft.print(buf);
tft.setTextColor(WHITE);
}
tft.println();
}
}

uint16_t bgr(uint16_t color)
{
return ((color & 0xF800) >> 11) | (color & 0x7E0) | (color & 0x1F) << 11;
}

void duffcolor(uint16_t color)
{
uint16_t pixel, x, y;
char done, buf[20];
uint16_t BGR = bgr(color);
for (done = 0, y = 0; y < 320 && !done; y++) {
for (x= 0; x < 240; x++) {
// pixel = readxy(x, y);
pixel = tft.readPixel(x, y);
if (pixel != BGR) {
done = 1;
sprintf(buf, "0x%04X @ %d, %d", pixel, x, y);
tft.println(buf);
break;
}
}
}
}

uint8_t aspect;
char *aspectname[] = {
"PORTRAIT", "LANDSCAPE", "PORTRAIT_REV", "LANDSCAPE_REV"
};

void loop(void)
{
uint16_t iter, color;
char buf[80];
aspect = (aspect + 1) & 3;
tft.setRotation(aspect);
for (iter = 0; iter < sizeof(colors) / sizeof(uint16_t); iter++) {
color = colors[iter];
tft.fillScreen(color);
tft.setTextColor(WHITE);
tft.setTextSize(1);
tft.setCursor(0, 0);
sprintf(buf, "ID=0x%04X Background=%04X %s",
tft.readID(), color, aspectname[aspect]);
tft.println(buf);
colordump(6 * 6, 0);
// duffcolor(color);
delay(5000);
}
}

and the code never uploads

The COM 10 is the Port for the Leonardo as it is stated on the tools>port tab
Is it a better recommendation to obtain another Arduino board for better speed, for example, an Uno R3, and which board exactly would be recommended?

I suspect that English is not your first language.
But it is important to read the Forum instructions e.g. how to paste code.
e.g. do not post screenshots of code.

Personally, I like to see specific example "name" and specific problem. e.g.

  1. I ran "diagnose_TFT_support.ino"
  2. I got a white screen
  3. The Serial Terminal shows this: copy-paste the Serial text

I suspect that something is broken. Can you borrow a different Arduino ?

David.

My apologies.

I ran readpixel_kbv. ino
I got a white screen
It gave me the error that avrdude: ser_open(): can't set com-state for ".\COM10” but ai made sure that the port was correct in the device manager and all the drivers were up to date.

I do not have another Arduino board but I can purchase the best bet for my shield, which it may be the Arduino Uno R3 correct?

readpixel_kbv.ino does NOT print to the Serial Terminal
diagnose_TFT_support.ino prints information to the Serial Terminal
LCD_ID_readreg.ino prints information to the Serial Terminal

I would buy a cheap Chinese UNO clone. I bet that you can buy a Uno clone from a local internet shop. You certainly can buy common items from UK Ebay shops.

Looking at Ebay.uk, Due clones seem to be very expensive !!

David.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.