Mega2560: TFT 1,8" just white

Dear forum.

I´m using a Joy-it mega2560 and a TFT 1,8" LCD screen (Joy-it). Neither with the code from vendor nor with any code I found I cannot get it running. The screen stays white.
I think there is a special code for the mega2560.

This is the code:

#include <TFT.h> // Hardware-specific library
#include <SPI.h>

#define CS   10
#define DC   9
#define RESET  8

TFT myScreen = TFT(CS, DC, RESET);

void setup(){
  myScreen.begin();
  myScreen.background(0,0,0);  // clear the screen with black
  delay(1000);  // pause for dramatic effect
}

void loop(){
  myScreen.stroke(255, 0, 0); // set the stroke color to red
  myScreen.line(0, 10, myScreen.width(), 10); // draw a line across the screen
  delay(1000);
  myScreen.noStroke(); // don't draw a line around the next rectangle
  myScreen.fill(0,255,0); // set the fill color to green
  myScreen.rect(0,20,myScreen.width(),10); //draw a rectangle across the screen
  delay(1000);
  myScreen.fill(0,0,255); // set the fill color to blue
  myScreen.stroke(255,255,255); // outline the rectangle with a white line
  myScreen.rect(0,45,myScreen.width(),45); // draw a fat rectangle
  delay(1000);
  myScreen.background(0,0,0); // clear the screen before starting again
  delay(1000);
}

The TFT library (TFT library) says that I have to use 51 and 52. But I dont know where I have to specify the pins.

Please help.
Thank you!

It is always wise to post a link to the actual display that you have bought.
Otherwise I have to guess. Is it this https://joy-it.net/en/products/RB-TFT1.8 ?

The manual shows you how to connect to a Uno.
Follow the same wiring on your Mega2560 but connect the GREEN wire to 52. And the YELLOW wire to 51.

Run the example program.

Incidentally, the TFT library might "work" but it is complete crap.
I suggest that you install and use the proper Adafruit_GFX and Adafruit_ST7735 libraries via the IDE Library Manager.
Run all the Adafruit_ST7735 examples.

David.

Hi David.
Thank you for your fast response.
With the mentioned libraries I got the tft running! It is exactly the type "RB-TFT1.8". Next time I will attach a picture.
Another problem were the 10k resistors I added before pins 8,9,10. After removal it worked.
Just one thing: Approx. a 3 pixel wide row on the right and on the bottom are not controlled and are showing wild colored pixels.
The only examples which are working are (ST7735):

  • graphictest
  • displayOnOfftest

best from Austria

Thanks for confirming the link to your display.

Always post links instead of pictures. e.g. Ebay sale page for your display.
Post pictures when you can not find a link e.g. photo of your wiring

I strongly advise using the proper Adafruit_ST7735 library.
Read the docs. Use the best initR() argument i.e. try BLACKTAB, REDTAB, ...

Panels vary. Find which "TAB" suits your Panel best. Then write on the back of the display pcb.

David.

Wow!
tft.initR(INITR_GREENTAB) does the job perfectly! Interesting ...

May I ask you which program you use to document your wirings?

And: If I want to use the "MISO" of the SD-card, may I connect it to the same pin as for the display?

Greets!

The manual has no schematic or pictures of the pcb. So I don't know what is printed on the pin header or what components are used.

As a general rule, you connect all SPI devices to the same 3.3V hardware SPI bus. (with separate /CS pin for each device)

SD_MISO would go to 50. SD_MOSI to 51, SD_SCK to 52. SD_CS to any GPIO pin.

David.

I cannot get the SD-card running on the TFT display since its running on 3,3V.
But I´ve bought one SD-card adapter HW-125 in advance which is running oob with your pin layout.

SD-Card SPI (MEGA 2560): 50 (MISO), 51 (MOSI), 52 (SCK), 53 (CS)

What program do you use to document your Arduino wirings?

We don't have your Joy-It pcb or your Joy-It schematic.

I don't expect you to reverse engineer a schematic. But you could say :

  1. There is a chip the same shape as the AMS1117 on the adapter board. Might be smaller.
  2. There is a chip the same shape as the P6550 but it has a different number.
  3. There are 4 Rs and 4 Cs

Most Ebay links have photos of the pcb. I can usually guess the schematic by looking at the components.

David.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.