Unresponsive TFT screen - am I doing something wrong?

Hi everyone

I need a second opinion.

This is my first time using a Touch screen. The screen has a ILI9486 chip driver and I'm using the UTFT library with the Mega clone.

I tried a bunch of things but cant seem to get anything to output onto the screen.

As soon as I plug the cable in, the screen lights up - but that's all.

The code compiles and loads ok.

I'm using 'Vanilla' example code that comes with UTFT.

Maybe I cant see the forest for the trees, or I bought a dud display module or the Mega is faulty ?.

Here is the link to where I bought it.

Following is the code

// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a quick demo of how create and use buttons.
//
// This program requires the UTFT library.
//
// It is assumed that the display module is connected to an
// appropriate shield or that you know how to change the pin
// numbers in the setup.
//

#include <UTFT.h>
#include <URTouch.h>

// Initialize display
// ------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : <display model>,19,18,17,16
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due       : <display model>,25,26,27,28
// Teensy 3.x TFT Test Board                   : <display model>,23,22, 3, 4
// ElecHouse TFT LCD/SD Shield for Arduino Due : <display model>,22,23,31,33
//
// Remember to change the model parameter to suit your display module!
UTFT    myGLCD(ILI9486,38,39,40,41);

// Initialize touchscreen
// ----------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : 15,10,14, 9, 8
// Standard Arduino Mega/Due shield            :  6, 5, 4, 3, 2
// CTE TFT LCD/SD Shield for Arduino Due       :  6, 5, 4, 3, 2
// Teensy 3.x TFT Test Board                   : 26,31,27,28,29
// ElecHouse TFT LCD/SD Shield for Arduino Due : 25,26,27,29,30
//
URTouch  myTouch( 6, 5, 4, 3, 2);

// Declare which fonts we will be using
extern uint8_t BigFont[];

int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

/*************************
**   Custom functions   **
*************************/

void drawButtons()
{
// Draw the upper row of buttons
 for (x=0; x<5; x++)
 {
   myGLCD.setColor(0, 0, 255);
   myGLCD.fillRoundRect (10+(x*60), 10, 60+(x*60), 60);
   myGLCD.setColor(255, 255, 255);
   myGLCD.drawRoundRect (10+(x*60), 10, 60+(x*60), 60);
   myGLCD.printNumI(x+1, 27+(x*60), 27);
 }
// Draw the center row of buttons
 for (x=0; x<5; x++)
 {
   myGLCD.setColor(0, 0, 255);
   myGLCD.fillRoundRect (10+(x*60), 70, 60+(x*60), 120);
   myGLCD.setColor(255, 255, 255);
   myGLCD.drawRoundRect (10+(x*60), 70, 60+(x*60), 120);
   if (x<4)
     myGLCD.printNumI(x+6, 27+(x*60), 87);
 }
 myGLCD.print("0", 267, 87);
// Draw the lower row of buttons
 myGLCD.setColor(0, 0, 255);
 myGLCD.fillRoundRect (10, 130, 150, 180);
 myGLCD.setColor(255, 255, 255);
 myGLCD.drawRoundRect (10, 130, 150, 180);
 myGLCD.print("Clear", 40, 147);
 myGLCD.setColor(0, 0, 255);
 myGLCD.fillRoundRect (160, 130, 300, 180);
 myGLCD.setColor(255, 255, 255);
 myGLCD.drawRoundRect (160, 130, 300, 180);
 myGLCD.print("Enter", 190, 147);
 myGLCD.setBackColor (0, 0, 0);
}

void updateStr(int val)
{
 if (stCurrentLen<20)
 {
   stCurrent[stCurrentLen]=val;
   stCurrent[stCurrentLen+1]=NULL;
   stCurrentLen++;
   myGLCD.setColor(0, 255, 0);
   myGLCD.print(stCurrent, LEFT, 224);
 }
 else
 {
   myGLCD.setColor(255, 0, 0);
   myGLCD.print("BUFFER FULL!", CENTER, 192);
   delay(500);
   myGLCD.print("            ", CENTER, 192);
   delay(500);
   myGLCD.print("BUFFER FULL!", CENTER, 192);
   delay(500);
   myGLCD.print("            ", CENTER, 192);
   myGLCD.setColor(0, 255, 0);
 }
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
 myGLCD.setColor(255, 0, 0);
 myGLCD.drawRoundRect (x1, y1, x2, y2);
 while (myTouch.dataAvailable())
   myTouch.read();
 myGLCD.setColor(255, 255, 255);
 myGLCD.drawRoundRect (x1, y1, x2, y2);
}

/*************************
**  Required functions  **
*************************/

void setup()
{
// Initial setup
 myGLCD.InitLCD();
 myGLCD.clrScr();

 myTouch.InitTouch();
 myTouch.setPrecision(PREC_MEDIUM);

 myGLCD.setFont(BigFont);
 myGLCD.setBackColor(0, 0, 255);
 drawButtons();  
}

void loop()
{
 while (true)
 {
   if (myTouch.dataAvailable())
   {
     myTouch.read();
     x=myTouch.getX();
     y=myTouch.getY();
     
     if ((y>=10) && (y<=60))  // Upper row
     {
       if ((x>=10) && (x<=60))  // Button: 1
       {
         waitForIt(10, 10, 60, 60);
         updateStr('1');
       }
       if ((x>=70) && (x<=120))  // Button: 2
       {
         waitForIt(70, 10, 120, 60);
         updateStr('2');
       }
       if ((x>=130) && (x<=180))  // Button: 3
       {
         waitForIt(130, 10, 180, 60);
         updateStr('3');
       }
       if ((x>=190) && (x<=240))  // Button: 4
       {
         waitForIt(190, 10, 240, 60);
         updateStr('4');
       }
       if ((x>=250) && (x<=300))  // Button: 5
       {
         waitForIt(250, 10, 300, 60);
         updateStr('5');
       }
     }

     if ((y>=70) && (y<=120))  // Center row
     {
       if ((x>=10) && (x<=60))  // Button: 6
       {
         waitForIt(10, 70, 60, 120);
         updateStr('6');
       }
       if ((x>=70) && (x<=120))  // Button: 7
       {
         waitForIt(70, 70, 120, 120);
         updateStr('7');
       }
       if ((x>=130) && (x<=180))  // Button: 8
       {
         waitForIt(130, 70, 180, 120);
         updateStr('8');
       }
       if ((x>=190) && (x<=240))  // Button: 9
       {
         waitForIt(190, 70, 240, 120);
         updateStr('9');
       }
       if ((x>=250) && (x<=300))  // Button: 0
       {
         waitForIt(250, 70, 300, 120);
         updateStr('0');
       }
     }

     if ((y>=130) && (y<=180))  // Upper row
     {
       if ((x>=10) && (x<=150))  // Button: Clear
       {
         waitForIt(10, 130, 150, 180);
         stCurrent[0]=NULL;
         stCurrentLen=0;
         myGLCD.setColor(0, 0, 0);
         myGLCD.fillRect(0, 224, 319, 239);
       }
       if ((x>=160) && (x<=300))  // Button: Enter
       {
         waitForIt(160, 130, 300, 180);
         if (stCurrentLen>0)
         {
           for (x=0; x<stCurrentLen+1; x++)
           {
             stLast[x]=stCurrent[x];
           }
           stCurrent[0]=NULL;
           stCurrentLen=0;
           myGLCD.setColor(0, 0, 0);
           myGLCD.fillRect(0, 208, 319, 239);
           myGLCD.setColor(0, 255, 0);
           myGLCD.print(stLast, LEFT, 208);
         }
         else
         {
           myGLCD.setColor(255, 0, 0);
           myGLCD.print("BUFFER EMPTY", CENTER, 192);
           delay(500);
           myGLCD.print("            ", CENTER, 192);
           delay(500);
           myGLCD.print("BUFFER EMPTY", CENTER, 192);
           delay(500);
           myGLCD.print("            ", CENTER, 192);
           myGLCD.setColor(0, 255, 0);
         }
       }
     }
   }
 }
}

First off. Please identify your pcb

Your link shows a 3.8/3.95 pcb with chips U3-U6
And a 3.95 pcb with chips U1-U6

There is no 4 inch pcb in the link.

Please compare the item on your desk with the photos in your link.
If there is no exact match: Describe any differences.

David.

Read the forum guidelines to see how to properly post code.

Hi everyone

Apologies for messing up the origin post.
I haven't done anything with Arduino or the Forum for quite some time and I'm just re-familiarising my self with things.

I included Images of the devices on the original Post.

The listing Is the actual device I bought.
They said it is 4 inch, but its actually 3.95 pcb (with chips U3-U6).

The eBay listing doesn't really provide much more detail and I cant find any technical document on this actual device anywhere.

From my understanding , pins required for the LCD are ,38,39,40,41 ?

i.e. the constructor would look like -> myGLCD(ILI9486,38,39,40,41);

sammypati:
I tried a bunch of things but cant seem to get anything to output onto the screen.

As soon as I plug the cable in, the screen lights up - but that's all.

A white screen?

Go on. Your photo in #0 shows a pcb with U1 - U6. And R4 mounted.

Remove R4 which is a 0R resistor. Solder it in the R5 position.

Don't worry if the 0R falls on the floor. A blob of solder will do the same job.

UTFT should be happy with the 16-bit interface.
Please report back.

If you do not have a soldering iron you can use MCUFRIEND_kbv library as a "SPECIAL".
Follow instructions in the how_to file.

USE_SPECIAL and USE_MEGA_8BIT_PORTC_SHIELD

I strongly advise you to enable the 16-bit interface.
USE_SPECIAL and USE_MEGA_16BIT_SHIELD

David.

I suspect that your display has a ST7796S and not ILI9486.

But I would expect UTFT to show something. UTFT does not have a ST7796 driver.

With MCUFRIEND_kbv you will use tft.begin(0x7796); instead of tft.begin(0x9486);

Your LCDWIKI link has very good English documentation.
Click on the Blue box at the top right: Other Languages

I have a low opinion of the LCDWIKI software but it should “work”

David.

Hi David

thanks for your response.

Resistor:
I moved the resistor to the R5 position
recompiled and run using the UTFT library.

MCUFRIEND_kbv:
I tried using MCUFRIEND_kbv
I loaded up the Aspet_KVB sample program
modified with #define USE_MEGA_16BIT_SHIELD & #efine USE_SPECIAL
but it didn't work
I changed pins in MCUFREIMD.h to MCUFRIEND_kbv(int CS=41, int RS=39, int WR=38, int RD=42, int _RST=40);
but it didn't work

Documentation:
I finally got the following documentation from the seller, but its mostly in Chinese and cant understand it.
http://www.lcdwiki.com/zh/3.95inch_Arduino_Display-Mega2560

I will also have a look at TheUNOGuy's suggestion too and get back ASAP.

I loaded up the Aspet_KVB sample program
modified with #define USE_MEGA_16BIT_SHIELD & #efine USE_SPECIAL
but it didn’t work
I changed pins in MCUFREIMD.h to MCUFRIEND_kbv(int CS=41, int RS=39, int WR=38, int RD=42, int _RST=40);
but it didn’t work

Please take care with typos. You can always edit and correct your own previous posts.

I suggest that you take notes of each step on paper.
Then use your notes when posting. Number each step.

Yes, it takes a few minutes.
But you will get accurate replies.

David.

hi David

Sorry for the typing errors.

I was updating my previous post to make it a bit clearer and I think you were responding at the same time so the sequence of our posts got screwed up.

Anyway , I tried ‘tft.begin(0x7796)’ but it didn’t work.

I’ve done a few projects in the past using the TFT library and LCD screens - they were all great.

This is the first Touch screen and its been crap from the start.

I think the display module is a dud. I’m resigned to the fact that I will have to throw it away and buy a new one.

I don’t want to buy another dud , do you have any suggestions what I should look for?

I suggest that you make notes.

It takes you 30 minutes to type everything up.
e.g. MCUFRIEND_kbv version
e.g. paste build report for graphictest_kbv.ino (or attach as .TXT file)
e.g. paste any report from Serial Terminal
e.g. any "edits" of library files or example sketch
...

Your display should work just fine. Likewise the Touch Controller. And SD card.

Time spent notes, typing, soldering, ... = 60 minutes.
Time spent waiting for "replacement display from China" = 8 - 58 days
(Or 2 days from local vendor.)

David.

Hi David

I followed your suggestions and here are the results

  1. MCUFRIEND_kbv version = 2.9.9

  2. I attached the build report

  3. I also attached the Serial output

  4. Code changes in the MCUFRIEND_kbv.h file- I change the constructor (see below) to include what I understand are the Display Shield pins

MCUFRIEND_kbv(int CS=41, int RS=39, int WR=38, int RD=42, int _RST=40);

  1. In the graphictest_kbv.ino I added the following

#define USE_MEGA_16BIT_SHIELD
#define USE_SPECIAL

thanks for your help with this

Sam

build.txt (20.5 KB)

MCUFRIEND_kbv.h (3.69 KB)

Serial Output.txt (42 Bytes)

graphictest_kbv.ino (18.4 KB)

Please post your .txt files ( The output ) in a post and not in a download..."How to use this forum - please read"...

Thanks for your feedback.

(1) ok
(2)

...
Compiling library "MCUFRIEND_kbv"
Using previously compiled file: C:\Users\SAMPAT~1\AppData\Local\Temp\arduino_build_936617\libraries\MCUFRIEND_kbv\MCUFRIEND_kbv.cpp.o
...
Using library SPI at version 1.0 in folder: C:\Users\Sam Pati\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\SPI 
Using library Adafruit_GFX_Library at version 1.10.1 in folder: C:\Users\Sam Pati\Documents\Arduino\libraries\Adafruit_GFX_Library 
Using library MCUFRIEND_kbv at version 2.9.9-Release in folder: C:\Users\Sam Pati\Documents\Arduino\libraries\MCUFRIEND_kbv 
Using library Adafruit_BusIO at version 1.5.0 in folder: C:\Users\Sam Pati\Documents\Arduino\libraries\Adafruit_BusIO 
Using library Wire at version 1.0 in folder: C:\Users\Sam Pati\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire

Unfortunately it is using a previously compiled file. If you had configured correctly it would have shown something like this:

Compiling library "Mcufriend_kbv"
"C:\\Users\\David Prentice\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10812 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino-1.8.12\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino-1.8.12\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Program Files (x86)\\Arduino-1.8.12\\hardware\\arduino\\avr\\libraries\\SPI\\src" "-IC:\\Users\\David Prentice\\Documents\\Arduino\\libraries\\Mcufriend_kbv" "-IC:\\Users\\David Prentice\\Documents\\Arduino\\libraries\\Adafruit_GFX_Library" "-IC:\\Users\\David Prentice\\Documents\\Arduino\\libraries\\Adafruit_BusIO" "-IC:\\Program Files (x86)\\Arduino-1.8.12\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Users\\David Prentice\\Documents\\Arduino\\libraries\\Mcufriend_kbv\\utility" "C:\\Users\\David Prentice\\Documents\\Arduino\\libraries\\Mcufriend_kbv\\MCUFRIEND_kbv.cpp" -o "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_654079\\libraries\\Mcufriend_kbv\\MCUFRIEND_kbv.cpp.o"
In file included from C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv\utility/mcufriend_shield.h:16:0,

                 from C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv\MCUFRIEND_kbv.cpp:35:

C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv\utility/mcufriend_special.h:472:2: warning: #warning USE_MEGA_16BIT_SHIELD [-Wcpp]

 #warning USE_MEGA_16BIT_SHIELD

  ^~~~~~~

In file included from C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv\MCUFRIEND_kbv.cpp:35:0:

C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv\utility/mcufriend_shield.h:18:2: warning: #warning WE ARE USING A SPECIAL CUSTOM DRIVER [-Wcpp]

 #warning WE ARE USING A SPECIAL CUSTOM DRIVER

  ^~~~~~~

Don't worry about the gobbledygook. The important lines are:

#warning USE_MEGA_16BIT_SHIELD
 #warning WE ARE USING A SPECIAL CUSTOM DRIVER

(3) ok. that is what you get from a write-only display

(4) no need to change the constructor. the arguments are just dummies

(5) you should edit the setup() function for your write-only shield. that is all. e.g.

    if (ID == 0xD3D3) ID = 0x9486; // write-only shield

You should NOT put the USE_SPECIAL macros in the sketch. But follow the instructions in the how_to file e.g. from
C:\Users\David Prentice\Documents\Arduino\libraries\Mcufriend_kbv\extras\mcufriend_how_to.txt

17. If you do not have a standard Uno Shield, you can add a SPECIAL to the mcufriend_special.h
    Edit mcufriend_shield.h:  #define USE_SPECIAL
    Edit mcufriend_special.h: e.g. #define USE_MEGA_16BIT_SHIELD
    If your "special" is write-only,  the library can not read the ID.  It always returns 0xD3D3

I am 100% confident that you will get your shield going.

Yes, I know that the "SPECIAL" procedure is a bit fiddly.

Note that you do not have to touch the library files again
But you will need to edit every sketch e.g.

    uint16_t ID = tft.readID(); //
    if (ID == 0xD3D3) ID = 0x9486; // write-only shield
    tft.begin(ID);

David.

p.s. your Touch Controller is different to Uno style shields and to most Mega shields. Get the TFT working first. Then I will show you how to use Touch and SD card on your Shield.

Hi David

I read the rules for posting. According to TheUNOGuy, I should post the output TXT file in the post and also attach it , but the file (and some others) were too large so I had no choice but attach them only.

I changed MCUFriend_special.h

#define USE_MEGA_16BIT_SHIELD

I also changed MCUFriend_sheild.h

#define USE_SPECIAL

Im not sure how to configure the IDE to do a full rebuild , so I manually deleted the object file and then recompiled & loaded .
Because of the size I also attached that file .
I noticed the warnings were present

#warning USE_MEGA_16BIT_SHIELD
 #warning WE ARE USING A SPECIAL CUSTOM DRIVER

I changed the program code to include
  if (ID == 0xD3D3) ID = 0x9486; // write-only shield

build.txt (23.9 KB)

graphictest_kbv.ino (18.4 KB)

mcufriend_shield.h (47.1 KB)

mcufriend_special.h (41.9 KB)

Everything looks good for 16-bit Shield.

I would expect Serial to report ID=0xD3D3
And graphictest_kbv.ino to run

Since you are using 16-bit interface R4=n.c., R5=0R you use

#define USE_MEGA_16BIT_SHIELD     // 2.14sec Mega2560 Shield

I would expect your 16-bit Shield to "work" with UTFT. 8-bit does not work with UTFT.

If you were using the default 8-bit interface R4=0R, R5=n.c you use

#define USE_MEGA_8BIT_PORTC_SHIELD // 4.7sec Mega2560 Shield

Don't worry about TheUNOGuy. All your files were too big to paste.
When there is a tricky build problem it is wise to attach the full-fat build report.

It is "better" to just paste changed lines from a publicly available library.
I am not going to trawl through whole files to look for changes. I just look at the "suggested" edits.

Of course I could diff your files. But I prefer to trust you.

David.

hi David ,
thanks for all your help
I went back through that ink they provided and converted their text to English . I eventually found some samples and a library and I now have it working .

I reactivated 8 bit because it didn't work until I did that .

I assume there is a macro or constant to enable 16 bit, but for now I'l run with 8 bit.

Once again I appreciate all your help.

Sam

I don't have your particular display. I do have the version with U3-U6 and know that that display works with

#define USE_MEGA_8BIT_SHIELD // 4.7sec Mega2560 Shield

Now that you have 8-bit working for LCDWIKI I would appreciate it if you try

If you were using the default 8-bit interface R4=0R, R5=n.c you use

#define USE_MEGA_8BIT_PORTC_SHIELD // 4.7sec Mega2560 Shield

David.

David

I used #define USE_MEGA_8BIT_PORTC_SHIELD and recompiled & loaded graphictest.ino
it seemed to work ok, but the writing was backwards.

I then tried FontSimple.ino and it seemed to work , but again the writing was backwards.

I copied TouchScreen.h and tried to compile Touch_Shield_New.ino but it go the following error
'Error compiling for board Arduino Mega or Mega 2560'.

Plug the Shield into your Mega2560. The USB cable should come out of the top of the Mega.

The USB cable is screen top.
The screen bottom has a ribbon and the 18x2 header pins.

Run graphictest_kbv.
Please report which Penguin screens are backwards. e.g. PORTRAIT is right-left or LANDSCAPE is bottom-top

Did you try 0x7796 instead of 0x9846 ?

I can fix all the rotations and directions easily. But I need accurate info. Or Penguin photos.

David.