A 1.8″ colour TFT gives a Mega project a proper dashboard: big numbers, coloured warnings and simple graphs, for about ₹350. It is an SPI display, and on the Mega hardware SPI lives on pins 51 and 52.
The display’s logic is 3.3 V, so each of the five signal lines from the Mega goes through a 1 kΩ / 2 kΩ divider. The sketch draws a title, colour bars and a counter that updates without flicker using an off-screen canvas — something only a board with the Mega’s RAM can afford in colour.
Wiring
| Arduino Mega 2560 | 1.8" ST7735 colour TFT (128×160) | Wire | Notes |
|---|---|---|---|
| 3.3V | LED | red | Backlight. Through the module’s resistor if fitted. |
| D52 | SCK | yellow | Via 1 kΩ / 2 kΩ divider |
| D51 | SDA | green | Via 1 kΩ / 2 kΩ divider — SDA on this display is SPI data (MOSI), not I2C. |
| D48 | A0 | blue | Via 1 kΩ / 2 kΩ divider — A0 = data/command (DC). |
| D49 | RESET | orange | Via 1 kΩ / 2 kΩ divider |
| D53 | CS | purple | Via 1 kΩ / 2 kΩ divider |
| GND | GND | black | |
| 5V | VCC | red | Most red 1.8″ boards have a regulator on VCC. |
3.3–5 V on VCC (on-board regulator on most boards) part, 5 V board. The ST7735 is a 3.3 V chip. ESP32 and Pico connect directly. On a 5 V Arduino, put a level shifter or 1 kΩ / 2 kΩ dividers on CS, RESET, A0, SDA and SCK — 5 V signals shorten the display’s life.
Board quirks
- The ST7735 is a 3.3 V chip. Many people wire it straight to 5 V pins and it works for a while; the dividers (or a 74HC4050) make it last.
- Hardware SPI on the Mega is 51 (MOSI) and 52 (SCK). Use those with the 3-argument constructor; any other pins fall back to slow software SPI.
- The flicker-free counter uses a 96×24 colour canvas: 4.6 KB of RAM. That fits in the Mega’s 8 KB, never in an Uno’s 2 KB.
- If the colours are inverted or a stripe of noise shows at the edge, change
INITR_BLACKTABtoINITR_GREENTABorINITR_REDTAB— the tab colour on the screen protector usually tells you which. - The SD-card slot on the back of some modules has its own SD_CS pin and shares SCK/MOSI/MISO.
Code
// 1.8" ST7735 TFT (128x160) on an Arduino Mega 2560's hardware SPI.
// SCK ← D52, SDA ← D51 (MOSI), CS ← D53, A0 ← D48, RESET ← D49 — each through a 1 kΩ / 2 kΩ
// divider (the ST7735 is a 3.3 V chip). VCC → 5V, GND → GND, LED → 5V (backlight).
// The live counter is drawn into a 16-bit off-screen canvas (4.6 KB of RAM) and copied in one go,
// so it never flickers — a trick the Mega's 8 KB of RAM allows and an Uno's 2 KB does not.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
const int8_t TFT_CS = 53, TFT_DC = 48, TFT_RST = 49;
Adafruit_ST7735 tft(TFT_CS, TFT_DC, TFT_RST);
GFXcanvas16 canvas(96, 24);
void setup() {
Serial.begin(115200);
tft.initR(INITR_BLACKTAB); // try INITR_GREENTAB / INITR_REDTAB if colours or edges look wrong
tft.setRotation(1); // landscape, 160x128
tft.fillScreen(ST77XX_BLACK);
tft.setTextColor(ST77XX_CYAN);
tft.setTextSize(2);
tft.setCursor(8, 8);
tft.print(F("FlashReady"));
tft.setTextSize(1);
tft.setTextColor(ST77XX_WHITE);
tft.setCursor(8, 32);
tft.print(F("Mega 2560 + ST7735"));
uint16_t colours[] = {ST77XX_RED, ST77XX_GREEN, ST77XX_BLUE, ST77XX_YELLOW, ST77XX_MAGENTA};
for (uint8_t i = 0; i < 5; i++) tft.fillRect(8 + i * 29, 100, 25, 20, colours[i]);
Serial.println(F("TFT ready"));
}
void loop() {
canvas.fillScreen(ST77XX_BLACK);
canvas.setTextColor(ST77XX_YELLOW);
canvas.setTextSize(2);
canvas.setCursor(0, 4);
canvas.print(millis() / 1000);
canvas.print(F(" s"));
tft.drawRGBBitmap(8, 56, canvas.getBuffer(), canvas.width(), canvas.height());
delay(200);
}// 1.8" ST7735 TFT (128x160) on an Arduino Mega 2560's hardware SPI.
// SCK ← D52, SDA ← D51 (MOSI), CS ← D53, A0 ← D48, RESET ← D49 — each through a 1 kΩ / 2 kΩ
// divider (the ST7735 is a 3.3 V chip). VCC → 5V, GND → GND, LED → 5V (backlight).
// The live counter is drawn into a 16-bit off-screen canvas (4.6 KB of RAM) and copied in one go,
// so it never flickers — a trick the Mega's 8 KB of RAM allows and an Uno's 2 KB does not.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
const int8_t TFT_CS = 53, TFT_DC = 48, TFT_RST = 49;
Adafruit_ST7735 tft(TFT_CS, TFT_DC, TFT_RST);
GFXcanvas16 canvas(96, 24);
void setup() {
Serial.begin(115200);
tft.initR(INITR_BLACKTAB); // try INITR_GREENTAB / INITR_REDTAB if colours or edges look wrong
tft.setRotation(1); // landscape, 160x128
tft.fillScreen(ST77XX_BLACK);
tft.setTextColor(ST77XX_CYAN);
tft.setTextSize(2);
tft.setCursor(8, 8);
tft.print(F("FlashReady"));
tft.setTextSize(1);
tft.setTextColor(ST77XX_WHITE);
tft.setCursor(8, 32);
tft.print(F("Mega 2560 + ST7735"));
uint16_t colours[] = {ST77XX_RED, ST77XX_GREEN, ST77XX_BLUE, ST77XX_YELLOW, ST77XX_MAGENTA};
for (uint8_t i = 0; i < 5; i++) tft.fillRect(8 + i * 29, 100, 25, 20, colours[i]);
Serial.println(F("TFT ready"));
}
void loop() {
canvas.fillScreen(ST77XX_BLACK);
canvas.setTextColor(ST77XX_YELLOW);
canvas.setTextSize(2);
canvas.setCursor(0, 4);
canvas.print(millis() / 1000);
canvas.print(F(" s"));
tft.drawRGBBitmap(8, 56, canvas.getBuffer(), canvas.width(), canvas.height());
delay(200);
}Library: Adafruit ST7735 and ST7789 Library (Adafruit) — compiled with Adafruit ST7735 and ST7789 Library 1.12.0.
Expected serial output
TFT readyTFT ready
Common errors
White screen
No data reaching the display: wrong pins, dividers too large, or CS/A0 swapped. Check with the 1 kΩ/2 kΩ values.
Colours wrong or offset by a few pixels
Wrong init tab. Try INITR_GREENTAB or INITR_REDTAB.