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,
- 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,
- I am going to need this later if I find out that I like Arduino programming, and
- 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 2.4 tft lcd touch shield pin mapping for Arduino Mega 2560 - Displays - Arduino Forum, 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?
Please advise.