# [SOLVED] Cannot get ITDB02-2.8 to work with Arduino Mega 2560 (screen blank)

Hello,

as I have stated before I am a complete idiot when it comes to Arduino, so I am in need of some help. While I am aware that programming graphical LCD’s with Arduino is considered non-trivial,

1. I have ordered more low-level stuff that I was planning to start with, but it has not arrived yet, and I really just want to get something working just to get that wonderful feeling,
2. I am going to need this later if I find out that I like Arduino programming, and
3. I am not a trivial programmer, I just don’t know anything about Arduino.

I am naturally using Henning Karlsen’s UTFT library.

So, the display backlight works fine, but I simply can’t get it to display anything using his demo program. I added some code to make an LED blink every now and then inside the loop, just to prove that the sketch is executing, and the LED does blink, so obviously the code is running, but the signals do not arrive at the screen (or the screen is broken, possibly). I have tried any number of pin combinations for the UTFT constructor, to no avail. The default of course says 38,39,40,41, but the general consensus on dx.com (where I got the screen) seems to be that it should be 19,18,17,16. As far as I can tell from the pinouts, it should be A5,A4,A3,A2(?). I have tried all of these. There is also some disagreement on the model number (not that I understand why), so I have tried several model numbers (ITDB28, ITDB32S, ITDB24D).

I have also tried following Karlsen’s guide on how to make Arduino UNO shields work on Mega by modifying HW_ATmega1280.h, and that did not work either.
(Electronics - Henning Karlsen)

The code I ended up with after following the aforementioned tutorial was this:

``````                //PORTA = VH;
//pulse_low(P_WR, B_WR);
//PORTA = VL;
//pulse_low(P_WR, B_WR); //these are not the pins we are looking for...
// *** BEGIN GHETTOHACK *** \\
if (VH & 0x01)
PORTE |= (1<<0);
else
PORTE &= (1<<0);
if (VH & 0x02)
PORTE |= (1<<1);
else
PORTE &= ~(1<<1);
if (VH & 0x04)
PORTE |= (1<<4);
else
PORTE &= ~(1<<4);
if (VH & 0x08)
PORTE |= (1<<5);
else
PORTE &= ~(1<<5);
if (VH & 0x10)
PORTG |= (1<<5);
else
PORTG &= ~(1<<5);
if (VH & 0x20)
PORTE |= (1<<3);
else
PORTE &= ~(1<<3);
if (VH & 0x40)
PORTH |= (1<<3);
else
PORTH &= ~(1<<3);
if (VH & 0x80)
PORTH |= (1<<4);
else
PORTH &= ~(1<<4);
pulse_low(P_WR, B_WR);
if (VL & 0x01)
PORTE |= (1<<0);
else
PORTE &= ~(1<<0);
if (VL & 0x02)
PORTE |= (1<<1);
else
PORTE &= ~(1<<1);
if (VL & 0x04)
PORTE |= (1<<4);
else
PORTE &= ~(1<<4);
if (VL & 0x08)
PORTE |= (1<<5);
else
PORTE &= ~(1<<5);
if (VL & 0x10)
PORTG |= (1<<5);
else
PORTG &= ~(1<<5);
if (VL & 0x20)
PORTE |= (1<<3);
else
PORTE &= ~(1<<3);
if (VL & 0x40)
PORTH |= (1<<3);
else
PORTH &= ~(1<<3);
if (VL & 0x80)
PORTH |= (1<<4);
else
PORTH &= ~(1<<4);
pulse_low(P_WR, B_WR);
// *** END GHETTOHACK *** \\
``````

and

``````		//DDRA = 0xFF;
//if (mode==16)
//	DDRC = 0xFF; removed since we need to use different pins
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
``````

Is this code correctly modified?

I see that in the HW_ATmega1280.h header file, there are several lines saying `#if defined(USE_UNO_SHIELD_ON_MEGA)`, which gives rise to two questions:

• Does this do all the work described in Karlsen’s tutorial for you, so you don’t have to change his code?
• How do you actually use this (I’m not a C++ programmer)?

The exact LCD I am using is this one:
http://store.iteadstudio.com/images/produce/Shield/Shields/AD28TFTshield/DS_Arduino-2.8-TFT-Touch-shield.pdf, and as mentioned in a previous post the Mega I am using is an XDRduino.

I have searched extensively all day (and yesterday), and I can’t find a solution that works for me.

Last question: As far as I understand it from berni_'s post here http://forum.arduino.cc/index.php?topic=147785, if I solder the pins 22-29 (are those the ones in the double row furthest from the USB connector?) to the correct pins on the LCD, I don’t need to change the library code because I have made the same changes to the hardware instead. I don’t wish to solder on my Arduino, and I don’t have the breakout cables (or Dupont or whatever they are called), so this is quite hard for me to do, but would it work? And also, which pins on the Arduino should be connected to which pins on the LCD?

OK I figured out how to use the USE_UNO_SHIELD_ON_MEGA thing (for those wondering, uncomment "#define USE_UNO_SHIELD_ON_MEGA 1", aka line 7 in libraries\UTFT\hardware\avr\HW_AVR_defines.h). Did it fix the problem? drumroll Nope. Absolutely no change. Disappointed drummer sighs

Ok, I made it all work. Since I loathe people who figure out stuff like this after having posted a thread about it and then neglect to tell other inquisitive minds about how they did it, I will be certain to point out what I did wrong.

Leave the code in HW_ATmega1280.h alone, that's not what we need to do. Just modifying HW_AVR_defines.h, by uncommenting line 7 "#define USE_UNO_SHIELD_ON_MEGA 1" is sufficient. The reason why this wasn't working for me was something completely obvious (like always, in these matters): it was all about the IDE's search paths. Because I created a new version of the UTFT library that had the modified line (called UTFTMega), but these files had the exact same file names, the IDE didn't actually use my modified version. That was probably because UTFT gets sorted before UTFTMega, so it reads those files first and found UTFT.h. The solution is therefore to not create a new version, just modify the one you have. Alternatively, you can make a new version that has different file names.

Thanks for the help on this, it was driving me crazy! I tried for most of the day last Saturday and never got it to work.

I feel you left a few thing out that will help others with this problem (just clarifying)

1) Modify the file : HW_AVR_defines.h by uncommenting line 7 "#define USE_UNO_SHIELD_ON_MEGA 1"

2) In main program (Like UTFT_Demo_320x240) Line 32 should read: "UTFT myGLCD(ITDB28,A5,A4,A3,A2);" NOTE the display type and the pin outs!

Thanks again, and I hope this helps others too.

Rick

Glad I could be of help to you. As I said, I really hate it when people figure stuff out and neglect to write down how they did it, so I try to always provide the solution if I make something work.