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.
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.
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):
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.