Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

1.8" ST7735 TFT with Arduino Mega 2560 — SPI 50–53 and a flicker-free canvas

Wire a 1.8" ST7735 colour TFT to an Arduino Mega 2560 on hardware SPI with dividers for 3.3 V logic, draw text and colours, and update numbers without flicker.

Arduino C++Verified — core avr 1.8.8, Adafruit ST7735 and ST7789 Library 1.12.0, 3 Nov 2026Compile-only

Community draft — report a mistake

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 2560Only the pins used are shown · 5 V logic1.8" ST7735 colour TFT (128×160)1k│2k1k│2k1k│2k1k│2k1k│2k3.3V5VGNDD48D49D51D52D53LEDSCKSDAA0RESETCSGNDVCC
Also needed: 5 × 1 kΩ and 5 × 2 kΩ resistors (or a 74HC4050 buffer powered from 3.3 V).
Every connection
Arduino Mega 25601.8" ST7735 colour TFT (128×160)WireNotes
3.3VLEDredBacklight. Through the module’s resistor if fitted.
D52SCKyellowVia 1 kΩ / 2 kΩ divider
D51SDAgreenVia 1 kΩ / 2 kΩ divider — SDA on this display is SPI data (MOSI), not I2C.
D48A0blueVia 1 kΩ / 2 kΩ divider — A0 = data/command (DC).
D49RESETorangeVia 1 kΩ / 2 kΩ divider
D53CSpurpleVia 1 kΩ / 2 kΩ divider
GNDGNDblack
5VVCCredMost 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_BLACKTAB to INITR_GREENTAB or INITR_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

st7735-mega.inoArduino C++Open in PlaygroundOpen in Playground
// 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

Serial Monitor · 115200Output
TFT 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.

↑↓ to move · Enter to open