MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields

3.2" (ILI9327), with TouchScren
https://www.wish.com/product/5b066ce79fad4248c8dad194

#define USE_SPECIAL, USE_OPENSMART_SHIELD_PINOUT_MEGA

3.5" (ILI9486)
https://www.wish.com/product/58768fc06dd28e28363b5ac5

regular default shield

2.8" (HX8347G), with TouchScren
https://www.wish.com/product/5b3608e17beacb052637efe6

#define USE_SPECIAL, USE_OPENSMART_SHIELD_PINOUT_MEGA
link shows board with RM68090 which is supported as default
if your board is printed HX8347G #define SUPPORT_8347D

In fact you could use OPENSMART_kbv class instead of MCUFRIEND_kbv class for the Open-Smart displays

#include <OPENSMART_kbv.h>
OPENSMART_kbv tft;

David.

Thank You,

I obviously miss that (and much more...). I will try it. As I said, I am very new in Arduino and C++.
....
Edit:
Yeah, I inherit OPENSMART class in my class, and everthing is, of course, working well. Next time, I will read all much carefully. You already did all, I must say excellent work. I just need to comment or uncomment
#define USE_SPECIAL
with USE_OPENSMART_SHIELD_PINOUT_MEGA
and that's all.
Again, realy great work.

Milan

Dear David,
I executed diagnose_TFT_support and received this message on serial monitor:

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

tft.readID() finds: ID = 0xD3D3

MCUFRIEND_kbv version: 2.9.9

Probably a write-only Mega2560 Shield
Try to force 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 users

I used the following code in arduino but it is not working! Please help me what should I do?

Best Regards,
Majid

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define BLUE 0x001F
#define WHITE 0xFFFF

void setup(void) {
Serial.begin(9600);
uint16_t ID = 0x9481;
tft.begin(ID);
tft.setRotation(2);
}

void loop(void) {
testText();
delay(2000);
}

unsigned long testText() {
tft.fillScreen(BLUE);
tft.setCursor(tft.width()/2, tft.height()/2);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.println("HELLO");
}

Thanks for writing on the Public Forum. It is not wise to PM.

Shields are designed to plug into the Arduino. Most shields can be read i.e. you can obtain the ID.

Since you seem to have a write-only display, please post a link or photo that shows the pcb view.

Please read the Forum instructions. Edit your message to put your "code" into a Code Window i.e. use the </> icon.

David.

Dear David,

Thank you. Here is the image of the mcufriend 2.4 inch spiflash module.

Best Regards,
Majid

Dear David,

Please find the attached file.

Majid

Your photo shows a current Mcufriend 2.4 inch Uno shield pcb.

Please plug the shield into your Uno.

Please run the LCD_ID_readreg example.
Copy-Paste the Serial Terminal to your message.

David.

Dear David,

Here is the message:

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) 04 04 04 04 Manufacturer ID
reg(0x0009) 09 09 09 09 09 Status Register
reg(0x0061) 61 61 RDID1 HX8347-G
reg(0x0062) 62 62 RDID2 HX8347-G
reg(0x0063) 63 63 RDID3 HX8347-G
reg(0x0064) 64 64 RDID1 HX8347-A
reg(0x0065) 65 65 RDID2 HX8347-A
reg(0x0066) 66 66 RDID3 HX8347-A
reg(0x0067) 67 67 RDID Himax HX8347-A
reg(0x0070) 70 70 Panel Himax HX8347-A
reg(0x00A1) A1 A1 A1 A1 A1 RD_DDB SSD1963
reg(0x00B0) B0 B0 RGB Interface Signal Control
reg(0x00B4) B4 B4 Inversion Control
reg(0x00B6) B6 B6 B6 B6 B6 Display Control
reg(0x00B7) B7 B7 Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF ILI9481, HX8357-B
reg(0x00C0) C0 C0 C0 C0 C0 C0 Panel Control
reg(0x00CC) CC CC Panel Control
reg(0x00D0) D0 D0 D0 Power Control
reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
reg(0x00DA) DA DA RDID1
reg(0x00DB) DB DB RDID2
reg(0x00DC) DC DC RDID3
reg(0x00EF) EF EF EF EF EF EF ILI9327
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
reg(0x00F6) F6 F6 F6 F6 Interface Control

Majid

Your readreg report shows a Shield that is NOT plugged in.

Please post a clear photo of your shield mating with the Arduino.
Every male pin should mate with a corresponding female socket.

David.

Dear David,

Actually I am using arduino nano instead of uno. I connected all pins including SD card pins and received the following message:

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 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 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 02 Inversion Control
reg(0x00B6) 00 0A 82 27 04 Display Control
reg(0x00B7) 00 07 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 30 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 02 02 NVM Read
reg(0x00D3) 00 00 93 40 ILI9341, ILI9488
reg(0x00D4) 00 00 00 00 Novatek ID
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 08 0E 12 05 03 09 47 86 2B 0B 04 00 00 00 00 GAMMA-P
reg(0x00E1) 00 08 1A 20 07 0E 05 3A 8A 40 04 18 0F 3F 3F 0F GAMMA-N
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control

Is it now plugged?

Majid

Yes, you have plugged it into all the correct Nano pins. But it was a lot of hard work.

I have a "Nano Adapter". It has regular Arduino headers and a socket for the Nano.
This turns the Nano into a regular Uno.

Anyway, this shows that you have an ILI9340

reg(0x00D3) 00 00 93 40 ILI9341, ILI9488

All the MCUFRIEND_kbv examples should find ID = 0x9340. All examples should work 100%.

Why would anyone use a Nano with a "Uno shield" ?
You will have dozens of wires. And everything will be "unreliable"

Please let us know if your display is ok.
Note that your Mcufriend pcb design is "crap" because there is no regulator chip. The old Mcufriend pcb had an AMS1117 regulator.
The 2.4 inch screens will probably work ok with Nano, Uno, Mega.
3.5 inch screens will draw too much current from the Arduino 3.3V pin.

David.

Dear David,

Here is the image of pins connection from arduino nano to mcufriend 2.4 inch TFT.
What should I do to display a simple text on TFT screen?

Best Regards,
Majid

IMG.jpg

Dear David,

Thank you very much for your help and consideration. When I use this code the screen of mcufriend module is blinking and it does not show any text. What is the problem?


#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

//#define BLUE 0x001F
#define RED 0xF800
#define WHITE 0xFFFF

void setup(void) {
Serial.begin(9600);
// tft.reset();
uint16_t ID = 0x9340;
tft.begin(ID);
tft.setRotation(2);
}

void loop(void) {
testText();
delay(50);
}

unsigned long testText() {
tft.fillScreen(RED);
tft.setCursor(tft.width()/2, tft.height()/2);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.println("HELLO");
}


Best Regards,
Majid

Please run the LCD_ID_readreg example.
Check that it is giving the correct output i.e. as in #2769

Then run all the other MCUFRIEND_kbv examples.

If an example does not work, quote the example sketch name.
Describe the problem.

I have no intention of even looking at your "code" until you have run the library examples.
And you have edited your message "code" to use Code Tags i.e. </> icon

David.

Dear David,

I omitted the delay and it is working perfectly with arduino nano :slight_smile:

Thank you very much again

Best Wishes
Majid

Seriously. Buy a cheap Chinese Uno clone. Shields are 100% reliable.

Run every example that comes with a library. It is the best way to learn. And it shows that your hardware is working ok.

David.

Hi, I have a 3.5" ili9486 tft shield (8-bit) which was designed for Uno. I'm currently using it on a mega (not as a shield, but with Dupont extensions). The problem is it takes about 6 seconds to display a bmp image from SD card, while the Uno take about 4 seconds. I believe it's because the port mapping on mega splits the data bus into 3 PORTS.

I'd like to have the pin assignments changed so that all lcd data pins are on either PORT A or PORT C, both of which have 8 pins available.

Below is the wiki for the lcd I have:
http://www.lcdwiki.com/3.5inch_Arduino_Display-UNO

Regards,
Iyaadh.

Go on. There is current thread about displaying RAW images.

There are often threads about wiring a Shield to PortA on a Mega2560.
e.g. USE_SPECIAL, USE_MEGA_8BIT_PROTOSHIELD

My showBMP example is designed for multiple formats. It will run on Uno
If you strip it down to 24-bit .BMP files and increase buffer sizes, it will run faster on a Mega.

Any "display from SD" will depend on SD hardware, access of FAT filesystem, decode of image format, blitting of pixels to TFT.

A Uno shield suffers from all these Mega features.
Hardware SPI is faster than bit-bang SPI. Smaller files mean less SPI traffic. .BMP images are big but simple to decode. .RAW files are smaller and simpler. .JPG files can be very SMALL but require CPU power and SRAM.

David.

Thanks, what are the pin assignments in PORTA for data0 to data7? I didn't find any info about data pins in mcufriend_special file.

I assume that anyone prepared to use a SPECIAL will be able to work it out for herself.

LCD_D0 - LCD_D7 go to digital #22 - 29
The LCD control signals remain on Analog #0 - 4

My Protoshield Adapter routes the SD pins to the Mega SPI header.
Which means that I can use hardware SPI.

David.