Go Down

Topic: 3.5 TFT TOUCHSCREEN mcufriend shield for UNO on MEGA 2560 (Read 33822 times) previous topic - next topic



Anyone still following this thread? I've got the same 3.5 in TFT as simonadam on Mega 2560. I got it working thanks to you Sir David. Now i can't figure out how to code it into hydroponics system described here -  http://forum.arduino.cc/index.php?topic=130344.0
I have a 3.5 mcufriend shield for UNO. it works on UNO.
will it work on mega.
is yours the same as mine, for UNo and made it work on mega?



If a shield works on a Uno,   it works on Mega, Zero, Due, ...

Select your board in the IDE.   Plug the shield into your board.   Compile your sketch and Upload to your Arduino board.



Hi Everyone!

I bought an LCD on eBay:

The link:

It is a „TFT 3.5 inch LCD Display Touch Screen UNO R3 Board Plug and Play Module Arduino„

I installed libraries:
1. MCUFRIEND_kbv (with the Arduino IDE)
2. Adafruit_GFX (with the Arduino IDE)
3. Touch-Screen-Library-master (downloaded from github)

Started some McUfriend Examples, like graphictest_kbv and graphictest_slim and GLUE_Demo_480x320.
They worked well.

After that I tried to use the touch screen.

I run Utouch_Calibr_kbv. It writes a text on the screen, but when I touch the screen, it does nothing.

I run LCD_ID_readreg, the output is:

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x000A) 00 08   Get Power Mode
reg(0x000C) 00 66   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   RDID2 HX8347-G
reg(0x0063) 00 00   RDID3 HX8347-G
reg(0x0064) 00 00   RDID1 HX8347-A
reg(0x0065) 00 00   RDID2 HX8347-A
reg(0x0066) 00 00   RDID3 HX8347-A
reg(0x0067) 00 00   RDID Himax HX8347-A
reg(0x0070) 00 00   Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00   RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 00 00   Inversion Control
reg(0x00B6) 00 00 00 00 00   Display Control
reg(0x00B7) 00 00   Entry Mode Set
reg(0x00BF) 00 02 04 94 81 FF   ILI9481, HX8357-B
reg(0x00C0) 00 10 3B 00 02 11 00 00 00   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 43   Power Control
reg(0x00D2) 00 01 22 00 00   NVM Read
reg(0x00D3) 00 01 22 00   ILI9341, ILI9488
reg(0x00D4) 00 01 22 00   Novatek ID
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-N
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 00 00 33 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 80 80 80   Interface Control
After that I run

diagnose_TFT_support, the output is:

Diagnose whether this controller is supported
There are FAQs in extras/mcufriend_how_to.txt

tft.readID() finds: ID = 0x9481

PORTRAIT is 320 x 480

Run the examples/graphictest_kbv sketch
All colours, text, directions, rotations, scrolls
should work.  If there is a problem,  make notes on paper
Post accurate description of problem to Forum
Or post a link to a video (or photos)

I rely on good information from remote usersdiagnose_TFT_support:

And lastly I run

Touch_shield_kbv the output is:

Found unknown LCD driver
Screen is 320x480
Calibration is:
LEFT = 920 RT  = 150
TOP  = 940 BOT = 120
Wiring is: PORTRAIT
YP=55 XM=56
YM=7 XP=6

So, I think it is an ILI9481 TFT.
But I am not able to make it work, as a touchscreen.
Is anyone who can advise me a library to use with these panel?
Or it is not a real touch screen or it is maybe a bad one?

I can be happy with any help.


Use the TouchScreen_Calibr_native sketch.
Adjust the ISPRESSED() function
Code: [Select]

bool ISPRESSED(void)
    // .kbv this was too sensitive !!
    // now touch has to be stable for 50ms
    int count = 0;
    bool state, oldstate;
    while (count < 10) {
        state = tp.z > 20;             //CHANGE VALUE TO 150 or 200
        if (state == oldstate) count++;
        else count = 0;
        oldstate = state;
    return oldstate;

You can debug your Touch by uncommenting the last line in readResistiveTouch()



Thank You David!

Changing from 20 to 200 it works!  :)

You are brilliant!



No.   I should have tested the "20" more thoroughly before the Release.


Hello David,
Could you please help?
Touch_shield_kbv is works, but looks like axis Mirrored. When I pressed Right Top Corner it is appears in Left Bottom Corner.
How to fix the problem? Thank you in advance!


Does the graphictest_kbv example work 100% ?
Please let me know if there is a problem.

For the Touch Screen,   read #123.

The Touch Panel has a physical geometry.   If you Calibrate in Portrait,   and display in Portrait_Rev all the points will appear to be 180 degrees wrong.





I bought this display: https://www.ebay.de/itm/272967866401 Waveshare 3,5inch 480x320 Resistive Touch TFT LCD Shield Arduino Display ILI9486

Here are some information about the display: https://www.waveshare.com/wiki/3.5inch_TFT_Touch_Shield

Unfortunately the display is not working with mcufriend library.

Could somebody help, please.

Code: [Select]
Run diagnose:
Diagnose whether this controller is supported
There are FAQs in extras/mcufriend_how_to.txt

tft.readID() finds: ID = 0x6868

This ID is not supported
look up ID in extras/mcufriend_how_to.txt
you may need to edit MCUFRIEND_kbv.cpp
to enable support for this ID
e.g. #define SUPPORT_8347D

New controllers appear on Ebay often
If your ID is not supported
run LCD_ID_readreg.ino from examples/
Copy-Paste the output from the Serial Terminal
to a message in Displays topic on Arduino Forum
or to Issues on GitHub

Code: [Select]

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 68 68 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 6C 6C 6C 6C Manufacturer ID
reg(0x0009) 69 69 69 69 69 Status Register
reg(0x000A) 6A 6A Get Power Mode
reg(0x000C) 6C 6C Get Pixel Format
reg(0x0061) 69 69 RDID1 HX8347-G
reg(0x0062) 6A 6A RDID2 HX8347-G
reg(0x0063) 6B 6B RDID3 HX8347-G
reg(0x0064) 6C 6C RDID1 HX8347-A
reg(0x0065) 6D 6D RDID2 HX8347-A
reg(0x0066) 6E 6E RDID3 HX8347-A
reg(0x0067) 6F 6F RDID Himax HX8347-A
reg(0x0070) 78 78 Panel Himax HX8347-A
reg(0x00A1) E9 E9 E9 E9 E9 RD_DDB SSD1963
reg(0x00B0) B8 B8 RGB Interface Signal Control
reg(0x00B4) BC BC Inversion Control
reg(0x00B6) BE BE BE BE BE Display Control
reg(0x00B7) BF BF Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF ILI9481, HX8357-B
reg(0x00C0) E8 E8 E8 E8 E8 E8 E8 E8 E8 Panel Control
reg(0x00C8) E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 GAMMA
reg(0x00CC) EC EC Panel Control
reg(0x00D0) F8 F8 F8 Power Control
reg(0x00D2) FA FA FA FA FA NVM Read
reg(0x00D3) FB FB FB FB ILI9341, ILI9488
reg(0x00D4) FC FC FC FC Novatek ID
reg(0x00DA) FA FA RDID1
reg(0x00DB) FB FB RDID2
reg(0x00DC) FC FC RDID3
reg(0x00E0) E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 E8 GAMMA-P
reg(0x00E1) E9 E9 E9 E9 E9 E9 E9 E9 E9 E9 E9 E9 E9 E9 E9 E9 GAMMA-N
reg(0x00EF) EF EF EF EF EF EF ILI9327
reg(0x00F2) FA FA FA FA FA FA FA FA FA FA FA FA Adjust Control 2
reg(0x00F6) FE FE FE FE Interface Control


Dec 17, 2017, 02:22 pm Last Edit: Dec 17, 2017, 02:33 pm by david_prentice
Yes,   you have bought an SPI shield which is write-only.    
Waveshare has taken a cheap 8080-16 display and driven it with a 16-bit shift register
There is no possibility of reading the data bus.

MCUFRIEND_kbv is for 8080-8 Parallel interface (or 8080-16 as a SPECIAL)

If Waveshare had used a proper SPI display everything would work perfectly.

I think that one of Bodmer's libraries will work with this board.
Personally,   I have little interest in a write-only board.
In fact I would be very interested in a genuine native-SPI ILI9486.

In Waveshare's defence,  at least they have put TFT, XPT2046, microSD on the same SPI bus.
The "popular" Mega2560 Shields just bit-bang the XPT2046 on GPIO pins.


Edit.   An MCP23017 or MCP23S18 would have enabled read-write access to the 8080-16 data bus.
However these devices have a maximum SCK=10MHz.   Ok for an AVR but would restrict faster MCUs.    Other 16-bit SPI Port Expanders are available.   



If you have an Arduino Mega 2560 and Mcufriend shield and are having issues with the display such as a black screen. Try this

Install the UTFT library (I did this on the Arduino IDE 1.8.5

Change this line to reflect the shield you have, in my case it is a ILI9486
The code is in the sample code UTFT_ViewFont

From this:
UTFT myGLCD(ITDB32S,38,39,40,41);

To this:
UTFT myGLCD(ILI9486,38,39,40,41);

This resolved the black screen issue for me and I was able to see a printout of the alpha-numeric test display.


Mar 26, 2018, 12:15 pm Last Edit: Mar 26, 2018, 12:15 pm by david_prentice
Your photo in #132 shows inverted colours in LANDSCAPE_REV direction.
So it certainly does not match the "ILI9486" model in the UTFT library.

This "Mcufriend mega2560" shield is write-only.
It is not possible to read the ID.   You can only guess.

I suspect that it is a Himax HX8357-B, HX8357-C, HX8357-D
This is supported by Bodmer's TFT_HX8357 library.
It is only supported as SPECIAL with MCUFRIEND_kbv library.
It is not supported at all by UTFT library.


Go Up