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
#define CS 10
#define DC 9
#define RESET 8
TFT myScreen = TFT(CS, DC, RESET);
myScreen.background(0,0,0); // clear the screen with black
delay(1000); // pause for dramatic effect
myScreen.stroke(255, 0, 0); // set the stroke color to red
myScreen.line(0, 10, myScreen.width(), 10); // draw a line across the screen
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
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
myScreen.background(0,0,0); // clear the screen before starting again
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.
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.
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):