2.8"TFT V1.0 & SD V1.0 with RS jpeg on Mega dtk help!

My name is John,

Im fairly new to the Arduino platform but I’ve been programing for decades. This one has me stumped due to vague documentaion and libraries that dont work for me. First I cant find clear documentation on any of the products, for example. What does the SD card and the TFT use for Select Pin? I’m thinking they both use pin 10 based on the Uno’s pin config. But I can’t confirm that. First here is what I’m working with.

I am using the Arduino Mega DTK, SD card v3.1, 2.8" TFT v1.0, and radio shack camera cat. 2760248. I have the Mega on the bottom, then pins 10,11,12,13 of the SD card shield bent inward and jumpered with these pins SD-pin10 to Mega pin53 and cut trace on bottom of SD card shield to seperate pin10 of the TFT so it can run to A4 on the same shield. So Sd Select on pin53 and TFT Select on pin A4 and then the rest of the SPI pins on the Mega,51,50,52. The jpeg camera I have hooked to mega 16,17.
So From Bottom to top it’s Mega, modified and pin diverted SD Shield, then TFT Screen on top.

can anyone help me?


Sounds good so far. What exactly is the problem? What symptoms and/or results are you getting? And also, which IDE version are you running?

I cant find a clear sketch that is complete and

works. I finally got the touch part to work and

to do that I had to modify the code to simply

display the data returned from the library call.

the sketch was not using the data for anything.

Now that I know what I’m looking for I’m noticing

that some sketches don’t have all the required

code or I don’t understand it enough to find it.

I have the IDE1.04 installed on d: drive with

it’s built in library and IDE1.05 installed on c:

program files/arduino with it’s built in library

and then my sketches on D: with my added

Libraries there in the folder

where I have a TFT, TFTv2, and TouchScreen

the TFT is a copy of the one in
“C:\Program Files (x86)\Arduino\libraries\TFT”

The first problem I’m having is how do I tell the

library function what my TFT chip select pin is?

I have now moved it to digital pin7 (that is

pin10 of the TFT conects to pin7 on the mega) a

cut trace and a jumper wire on the SD card shield

handle that. while the SPI pins get routed to

mega 50-53 with 53 going to pin of the SD card

for chip select.

some of the sketches I find don’t have any place

at all to tell it what my TFT select pin is and

others I’m not sure about the naming of the

like TFT_CS or CS if it’s CS how would the TFT

know thats for it as oposed to the SD card? in

this example that has the touch part displaying

numbers I changed the name to CS. Also some of

the documentation says that I need to put in my

sketches the coding to pull the CS low myself

then back high when I’m done. but I notice that

the library functions are already doing that.

but where did they get the pin # for CS?
the following Sketch does nothing on the screen.

I see the pin7 pulsing

the TFT.h library file has this code in it that I

can’t figure out.
#define DDR_CS DDRB
#define CS_BIT 0x04
#define CS_HIGH {PORT_CS|=CS_BIT;}
#define CS_LOW {PORT_CS&=~CS_BIT;}
am I right to assume it’s using Mega pin 51 for

Chip Select?
trying to change it to pin7. But I wouldn’t

have found that if I wasn’t trying to find

something else.

actually this is the part that pretains to the

#define DDR_CS DDRF
#define CS_BIT 0x10
#define CS_HIGH {PORT_CS|=CS_BIT;}
#define CS_LOW {PORT_CS&=~CS_BIT;}
I must have changed this to pin A4 before I moved

the jumper wire.

but the next code grouping says :
#define DDR_RS DDRB
#define RS_BIT 0x08
#define RS_HIGH {PORT_RS|=RS_BIT;}
#define RS_LOW {PORT_RS&=~RS_BIT;}

that would be pin 50 right? Pin 50 is MISO. So

what do they mean by RS? Does RS mean MISO? Why

do they have to keep changing abr. var. names?

and my next question. after the above statements,

does RS_HIGH flip pin50 to a high output? like

RS_HIGH; // flips pin50 high and:
RS_LOW;// puts it back low again?
but at 50 times the speed of
is that correct?
I could find no clear documentation about that

so is this going to work when I change that code

section to read

#define DDR_CS DDRH
#define CS_BIT 0x10
#define CS_HIGH {PORT_CS|=CS_BIT;}
#define CS_LOW {PORT_CS&=~CS_BIT;}
this should be pin7

I will try this now thanks for answering.

no it still doesn’t work. I have nothing left to try

thank you for responding but still need help.

my current sketch is here

#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#include <cstddef.h>
#include <SPI.h>

#define YP A2 // must be an analog pin, use “An” notation!
#define XM A1 // must be an analog pin, use “An” notation!
#define YM A0 // can be a digital pin, this is A0
#define XP A3 // can be a digital pin, this is A3
#define CS 7 // tft select pin for SPI
#define MOSI 51
#define MISO 50
#define SCK 52

#define TS_MINX 140
#define TS_MAXX 900
#define TS_MINY 120
#define TS_MAXY 940

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); //init TouchScreen port pins
int rD=0,finger=0;
const int TxPin = 14;// seting up mySerial com to LCD display
#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

void setup(){out(TxPin);digitalWrite(TxPin, HIGH);

void loop(){buttons(); // Print Char to TFT //
Tft.fillRectangle(200,60,50,15,BLACK); // Clear old text
Tft.fillRectangle(200,120,60,15,BLACK); // Clear old text
Tft.fillRectangle(200,150,60,15,BLACK); // Clear old text
Tft.fillRectangle(200,180,60,15,BLACK); // Clear old text
delay(1000);} // delay to read screen

void drawScreen(){
Tft.drawRectangle(0, 3, 238,30,BLUE); // HEADER TITLE
Tft.drawString(“Display Data”,20,15,2,WHITE); // header name
Tft.drawRectangle(0, 196, 70, 30,BLUE);
Tft.drawString(“Pump 1”, 15, 208, 1, WHITE);
Tft.drawRectangle(80, 196, 70, 30, BLUE);
Tft.drawString(“Pump 2”, 95 , 208 , 1, WHITE);
Tft.drawRectangle(160, 196, 70, 30, BLUE);
Tft.drawString(“Fans”, 175, 208, 1, WHITE);
Tft.drawRectangle(0, 236, 110,30,BLUE);
Tft.drawString(“Return Pump”, 15, 248,1,WHITE);
Tft.drawRectangle(120, 236, 110, 30, BLUE);
Tft.drawString(“Skimmer”, 150, 248, 1, WHITE);
Tft.drawRectangle(0, 276, 110, 30, BLUE);
Tft.drawString(“Halides”, 25, 286, 1, WHITE);
Tft.drawRectangle(120, 276, 110, 30, BLUE);
Tft.drawString(“Actnitcs”, 140, 286, 1, WHITE); }

void buttons(){
Point p = ts.getPoint();
p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);
///////////////////////////////////////////////////////////////////////////For Pump 1

// my standard functions+
int in(int pin){pinMode(pin,INPUT);}
int out(int pin){pinMode(pin,OUTPUT);}
int dR(int pin){rD=digitalRead(pin);return rD;}
int dW(int pin, int logic){if(logic==1){digitalWrite(pin,HIGH);}else{digitalWrite(pin,LOW);}}
int pU(int pin){pinMode(pin,INPUT_PULLUP);}
int dH(int pin){digitalWrite(pin,HIGH);}
int dL(int pin){digitalWrite(pin,LOW);}
int aW(int pin,int duty){analogWrite(pin,duty);}
int aR(int pin){rD=analogRead(pin);return rD;}
void iPU( int pin){pinMode(pin,INPUT_PULLUP);}

void cursorL(int spaces){for(int a=0;a<spaces;a++){mySerial.write(8);}}
void cursorR(int spaces){for(int a=0;a<spaces;a++){mySerial.write(9);}}
void cursorD(){mySerial.write(10);}
void cursorNotBlinkNot(){mySerial.write(22);}
void cursorNotBlink(){mySerial.write(23);}
void cursorBlinkNot(){mySerial.write(24);}
void cursorBlink(){mySerial.write(25);}
void cursorLine1(){mySerial.write(128);}
void cursorLine2(){mySerial.write(148);}
int curs(int line,int spaces){
int p(int prn){mySerial.print(prn);}//print an integer
void sp(){mySerial.print(" ");}
void clr(){mySerial.write(12);delay(50);}//only clear
void snd1(){mySerial.write(212);mySerial.write(220);} // sou8nd a tone FROM THE DISPLAY
void openDisplay(){mySerial.write(12);mySerial.write(17);delay(5);}//Clear display steer backlight on and add Required delay
void closeDisplay(){mySerial.write(18);}//steer light off
void clearDisplay(){mySerial.write(12);}//only clear
void lineF(){mySerial.write(13);}// line feed
void onDisplay(){mySerial.write(17);delay(5);}
void offDisplay(){mySerial.write(18);}//steer light off
void lF(){mySerial.write(13);}
int showHex(int hex){if(hex>=0 && hex<10){mySerial.print(hex);}
// end my standard functions