First you should know the breakout board is 3.3V logic level and it can not connect to 5V Arduino board directly.
You have to choice:
1: Do not plug USB cable and supply external 3.3V power for the 5V pin on the Arduino board, so that it works at 3.3V logic level.
2: Use some 3.3V MCU development board, such as OPEN-SMART UNO R3 that has a 5V/3.3V switch to select 5V or 3.3V logic level.
Your library is a hacked version of a very old MCUFRIEND_kbv
I have no connection with either Open-Smart or with Mcufriend. Neither company has ever contacted me.
If you provide the necessary 3.3V level shifters and 3.3V power I am sure that your hacked library would work.
I know that genuine MCUFRIEND_kbv should work with the correct electronics.
Few months ago I had OpenSmart 3.5 with RM68140 driver. I used same library and first option (Do not plug USB cable and supply external 3.3V power for the 5V pin on the Arduino board, so that it works at 3.3V logic level.) and everything worked fine.
But now, I tried same option and it doesnt work...
Is there anything what I need to change in MCUFRIEND_kbv.cpp or MCUFRIEND_kbv.h files?
Seriously. Either buy an Arduino Shield that has level-shifters on the pcb.
Or buy a proper 3.3V Arduino like Zero, Due, ...
It is very risky to remove the display every time you want to plug the USB cable into your Mega2560.
I suppose that you could remove the USB cable completely. Use an external 3.3V power supply, external 3.3V Serial link, external programmer e.g. ATMEL-ICE.
But you will get very annoyed.
TFT shields are very cheap nowadays. Due clones are very cheap. You have lots of options.
Do you think, if this would be solution of my problem?
it says "The maximum voltage that the I/O pins can provide or tolerate is 3.3V."
Specifications
Microcontroller AT91SAM3X8E
Operating Voltage 3.3V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 54 (of which 12 provide PWM output)
Analog Input Pins 12
Analog Outputs Pins 2 (DAC)
Total DC Output Current on all I/O lines 130 mA
DC Current for 3.3V Pin 800 mA
DC Current for 5V Pin 800 mA
SRAM 96 KB (64 + 32 KB)
Clock Speed 84 MHz
I bought Arduino DUE, as your suggestion for my OPENSMART 3.5 R61518 display. But there is a problem... When I tried to compile my program for Arduino DUE, there is error during compiling:
In file included from C:\Users\RS-Servis\Documents\Arduino\libraries\OPENSMART_TFT\MCUFRIEND_kbv.cpp:40:0:
C:\Users\RS-Servis\Documents\Arduino\libraries\OPENSMART_TFT\mcufriend_shield.h:1:20: fatal error: avr/io.h: No such file or directory
#include <avr/io.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino Due (Programming Port).
is intended for Open-Smart Shields. I don't think that I have ever recommended that anyone should use an Open-Smart Shield on a Due. The Open-Smart Reset chip interferes with the Due reset.
You have a 3.3V display with no extra electronics.
You do not have an Open-Smart Shield. So you do not use any SPECIAL
You just use the regular Mcufriend wiring e.g. to 2-9, A0-A4
MCUFRIEND_kbv does build and run with regular Mcufriend Shields on a Due.
MCUFRIEND_kbv does build and run with USE_OPENSMART_SHIELD_PINOUT_DUE for a Open-Smart Shield.
I possess a 3.3V Open-Smart similar to you. But with ILI9225
I made a Protoshield that has a 16x1 socket to receive the Open-Smart and routes to regular Arduino pins 2-9 and A0-A4
David.
Edit. Added power, LED connections.
Run LCD_ID_readreg.ino. It uses no libraries. It verifies your wiring. Copy-Paste from Serial Terminal.
Post a clear photo of your wiring. e.g. with coloured wires that are pulled straight. so we can identify each end of each wire.
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)