3.5 inch adafruit touch screen breakout display with arduino mega issues

Hi all, I have purchased the latest adafruit 3.5 inch touchscreen breakout for my project.I have tested it with Arduino UNO and it works perfectly as the display part as well as touch screen part..But on interfacing with Arduino Mega , It's display part working properly and touch is does noy detecting...please help me to fix the problem...i am stucked.. :( :( :(

Expecting kind respondses.....as sooon......please halp.....

Thanks.

Can you give us a link to the screen, pictures of your setup, and code pasted into code tags? We can help you once that happens. Otherwise, we have nothing to go on.

Sir, Here i am posting the connection images.

Thanks

https://drive.google.com/file/d/0B9nSEL ... sp=sharing https://drive.google.com/file/d/0B9nSEL ... sp=sharing https://drive.google.com/file/d/0B9nSEL ... sp=sharing https://drive.google.com/file/d/0B9nSEL ... sp=sharing https://drive.google.com/file/d/0B9nSEL ... sp=sharing

Your "URLs" just produce : Sorry, the file you have requested does not exist.

If your programs work on the Uno, they should work on a Mega too. Please post a link to the actual display that you have bought. Please attach or paste your working Uno sketch and your non-working Mega sketch.

As a general rule, Adafruit items come with examples that will work out of the box. You might need to change some #defines for your wiring for a Mega. You might need to change the arguments in a constructor().

Otherwise, the example does not need any alteration. So you could simply say which example and just paste your defines and constructor to your message.

In fact, the latter approach is more likely to get a response. If in doubt, attaching complete code is always useful. We can show you where to change defines.

David.

Sir,
Here i am attaching the code which works perfectly with UNO and partialy with mega(touch is not sensing)

// Paint example specifically for the TFTLCD breakout board.
// If using the Arduino shield, use the tftpaint_shield.pde sketch instead!
// DOES NOT CURRENTLY WORK ON ARDUINO LEONARDO

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>

#if defined(SAM3X8E)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7

// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
// D0 connects to digital pin 22
// D1 connects to digital pin 23
// D2 connects to digital pin 24
// D3 connects to digital pin 25
// D4 connects to digital pin 26
// D5 connects to digital pin 27
// D6 connects to digital pin 28
// D7 connects to digital pin 29

// For the Arduino Due, use digital pins 33 through 40
// (on the 2-row header at the end of the board).
// D0 connects to digital pin 33
// D1 connects to digital pin 34
// D2 connects to digital pin 35
// D3 connects to digital pin 36
// D4 connects to digital pin 37
// D5 connects to digital pin 38
// D6 connects to digital pin 39
// D7 connects to digital pin 40

#define YP A3 // must be an analog pin, use “An” notation!
#define XM A2 // must be an analog pin, use “An” notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we’re using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
// optional
#define LCD_RESET A4

// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
Serial.begin(9600);
Serial.println(F(“Paint!”));

tft.reset();

uint16_t identifier = tft.readID();

if(identifier == 0x9325) {
Serial.println(F(“Found ILI9325 LCD driver”));
} else if(identifier == 0x9328) {
Serial.println(F(“Found ILI9328 LCD driver”));
} else if(identifier == 0x7575) {
Serial.println(F(“Found HX8347G LCD driver”));
} else if(identifier == 0x9341) {
Serial.println(F(“Found ILI9341 LCD driver”));
} else if(identifier == 0x8357) {
Serial.println(F(“Found HX8357D LCD driver”));
} else {
Serial.print(F(“Unknown LCD driver chip: “));
Serial.println(identifier, HEX);
Serial.println(F(“If using the Adafruit 2.8” TFT Arduino shield, the line:”));
Serial.println(F(” #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F(“should appear in the library header (Adafruit_TFT.h).”));
Serial.println(F(“If using the breakout board, it should NOT be #defined!”));
Serial.println(F(“Also if using the breakout, double-check that all wiring”));
Serial.println(F(“matches the tutorial.”));
return;
}

tft.begin(identifier);

tft.fillScreen(BLACK);

tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
tft.fillRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, GREEN);
tft.fillRect(BOXSIZE
3, 0, BOXSIZE, BOXSIZE, CYAN);
tft.fillRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, BLUE);
tft.fillRect(BOXSIZE
5, 0, BOXSIZE, BOXSIZE, MAGENTA);
// tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, WHITE);

tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
currentcolor = RED;

pinMode(13, OUTPUT);
}

#define MINPRESSURE 10
#define MAXPRESSURE 1000

void loop()
{
digitalWrite(13, HIGH);
TSPoint p = ts.getPoint();
digitalWrite(13, LOW);

// if sharing pins, you’ll need to fix the directions of the touchscreen pins
//pinMode(XP, OUTPUT);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
//pinMode(YM, OUTPUT);

// we have some minimum pressure we consider ‘valid’
// pressure of 0 means no pressing!

if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
/*
Serial.print("X = “); Serial.print(p.x);
Serial.print(”\tY = “); Serial.print(p.y);
Serial.print(”\tPressure = "); Serial.println(p.z);
*/

if (p.y < (TS_MINY-5)) {
Serial.println(“erase”);
// press the bottom of the screen to erase
tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
}
// scale from 0->1023 to tft.width
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
/*
Serial.print("("); Serial.print(p.x);
Serial.print(", “); Serial.print(p.y);
Serial.println(”)");
*/
if (p.y < BOXSIZE) {
oldcolor = currentcolor;

if (p.x < BOXSIZE) {
currentcolor = RED;
tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE2) {
currentcolor = YELLOW;
tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
3) {
currentcolor = GREEN;
tft.drawRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
4) {
currentcolor = CYAN;
tft.drawRect(BOXSIZE3, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
5) {
currentcolor = BLUE;
tft.drawRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
6) {
currentcolor = MAGENTA;
tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
}

if (oldcolor != currentcolor) {
if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
if (oldcolor == GREEN) tft.fillRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, GREEN);
if (oldcolor == CYAN) tft.fillRect(BOXSIZE
3, 0, BOXSIZE, BOXSIZE, CYAN);
if (oldcolor == BLUE) tft.fillRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, BLUE);
if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE
5, 0, BOXSIZE, BOXSIZE, MAGENTA);
}
}
if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
}
}
}

Sir, First off sorry for the inconvenience caused by my shared link...i have already posted my code that does'nt works with mega and perfect with UNO...below i am sharing the images related with screen Mega interfacing and also the actual product link.

Thanks

https://learn.adafruit.com/adafruit-3-5-color-320x480-tft-touchscreen-breakout/8-bit-wiring-and-test

Your link shows you how to connect a Uno. It describes how to connect a Mega. Like all Adafruit products, they provide good documentation and advice.

It specifically says that it does NOT describe 8-bit parallel on a Leonardo. It suggest that you use SPI.

If you really want to use a Leonardo, wire the breakout exactly like a Mcufriend Uno Shield. Then the Leonardo will work with MCUFRIEND_kbv library.

David.

Sir,
I have actually need to connect it with Arduino mega not with Leonardo …

Go on. It tells you exactly which pins to connect on the Mega. So the TFT display should work 100%.

It does not tell you about XP, YM for the Mega. If XP is 8 (LCD_D0) on a Uno, I would define it as 22 (LCD_D0) on the Mega.

Always test the examples on the recommended hardware first. e.g. the Uno. Then you know if and how it should work when you rebuild it for the Mega.

David.

sir,

I have interfaced it with UNO and it works perfectly....but on converting to MEGA it's display part is working perfectly...but the touch is not detecting....

Sir,

Thank you...sir...solved the issue...Once again thanks for your support.... :) :)

Thanks.

Hi, I'm looking to wire a tft to a Mega without using a shield because I've another shield plugged.I understand reading the code where D0 -> D7 will gone plugged (pins 22 -> 28) but I don't understand if is possible to change analog pins from A0 -> A4 to A5 -> A9 and if I've to change YM to 23 XP to 22 and XM to A7 and YP to A8, that's right? Another little question, 3.3 Volts pon is't used? Tks for your kind attention.

Yes. It is very important to use the 3.3V pin.

God invented Shields. Just plug the shield into the Arduino.

If you want to re-route wires, use a Protoshield as a Sandwich Adapter for the TFT.

You can re-route wires wherever you want. Routeing the data bus to PORTA (D22-D29) gives much faster performance. LCD_WR, LCD_RS are normally XM, YP and need to be on Analog pins for the Touch Screen.

You test your wiring with the LCD_ID_readreg sketch. Post your #defines. I will write the SPECIAL for you.

David.

Firstly, thank you David, for your quick answer. Secondly, yes "God invented shields", but Evil multiplicated than :) . I've Mega, one Motor Shield like this Pixnor L293D Drive Motor Shield per Arduino Duemilanove UNO Mega R3 AVR ATMEL Now, all the pins Uno like, are wiring. My Tft is this : Kuman UNO R3 3.5 TFT Touch Screen with SD Card Socket for Arduino MEGA 2560 Board Module with touch function SC3A-1 (Maybe links to a 2.8" tft but when I've bought linking to 3.5). For this trouble, or I put tft on Uno pins and wiring motor shield, or wiring tft.... :) Maybe first option is better, but I don't know how to wiring the motor shield, do you have some ideas?

Your Motor shield uses the regular Uno headers.

Your screen link does not work. I found this Kuman screen

Life becomes very complicated when you hand-wire complex screens. I strongly recommend that you use soldered connections on a Protoboard or Protoshield.

Note that you must suppy a 3.3V reference to the display. All the LCD_xxx pins can work with any digital pins for the TFT. The Touch needs at least 2 Analog pins.

It is simpler with SPI displays. Just ensure that you use level shifters for 3.3V screens. The TFT, SD, Touch can all work on the same SPI bus.

David.

Tks David, the tft you linked is the same as mine. 'Cause I have a ATX OC power supply I could take 3.3 and 5 volts. But I don't understand what meaning SPI, or better, I have't never used it. Some news material to read :) ! Do you have some pages, or tutorials, where I can increase my knowledege?

There are several popular 3.3V SPI screens that use SPI ILI9341 There are very few proper 320x480 SPI screens but Adafruit has an HX8357D breakout.

Screens for Raspberry Pi are SPI. But most are simply kludged parallel 8080-16 driven by a shift register. And of course these are 3.3V logic.

Some Adafruit, Waveshare, EastRising displays are designed for 5V operation. Read adverts VERY carefully. Most Ebay Vendors lie through their teeth.

I am horrified by ATX power supplies. God gave you Arduino Shields. Use them. It might be simpler to mount TFT on a Uno, Motor shield on another Uno. Talk to each other via SPI or UART.

David.

About #define, I'have wiring LCD_D0 to pin 22 of Mega and D1 23, D2 24 ... D7 29, then I've took it Analog pin A8 for LCD_CS, A9 LCD_RS, A10 LCD_WR, A11 LCD_RD and finally A12 LCD_RST. +5 and GND come from motor shield. Maybe the error is thatI've not wired 3.3V. Accipicchia (italian word for I'm really stupid) :)

But please lead me along the right wiring ;)

Yes, how many times do I have to say 3.3V pin must be connected ?

Connect the correct wires.

define all the pins in LCD_ID_readreg sketch.

Copy-paste your #defines to your message. Copy-paste the LCD_ID_readreg output to your message.

David.

Ok I'll doing when I'm at home. Now I'm driving up and down hill in South Piedmont (North West of Italy, good wines and food).