ST7735 1.8 inch TFT

The 1.8 inch 128x160 color TFT on the red board with the SD card slot on the back. Aliases: 1.8 inch TFT, ST7735S, 128x160 TFT.

The controller speaks the same command set as the ILI9341: a column window, a row window, then pixels, with DC saying which bytes are commands. The same code in Mokxi runs both.

Pins

Pin What it does
VCC Supply; the board has a regulator, so 5 V is fine.
GND Ground.
CS Chip select, active low.
RESET Reset, active low.
A0 What this board calls DC: low for a command, high for data.
SDA The SPI data in. It is not I2C, whatever the name says.
SCK The SPI clock.
LED The backlight. Pull it low and the picture goes out.

The SD card's pins are not on the part.

Properties

tab: black (the default) or green, the color of the tab on the panel's protective film. It is how the makers mark where the 128x160 of glass sits in the chip's 132x162 of memory. A black tab uses all of it; a green tab's glass starts at column 2 and row 1. Set it to match the module you are copying, and set the sketch's initR to match it.

What the model gets right

The offset. The chip's memory is bigger than a green tab's glass, and the part stores only the glass, so a sketch initialized for the wrong tab draws two columns and a row where nobody can see them and leaves a stripe of black along two edges, which is the picture that sends everyone looking for the other initR. MADCTL rotation, the window, 16-bit and 18-bit pixels, sleep, display on and off, inversion and the backlight pin all behave as they do on the ILI9341.

What it does not model

The color order. The tabs also differ in whether the glass is RGB or BGR, and a library set for the wrong one swaps red and blue on the bench. Here a pixel is always the color that was written. 12-bit color is taken as 16-bit. Nothing is read back. There is no timing: the 120 ms the datasheet asks for after leaving sleep is not enforced. Gamma and frame rate change nothing.

Code

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>

Adafruit_ST7735 tft(10, 9, 8);   // CS, A0, RESET; SDA on 11, SCK on 13

void setup() {
  tft.initR(INITR_BLACKTAB);
  tft.fillScreen(ST77XX_BLACK);
  tft.setTextColor(ST77XX_GREEN);
  tft.setCursor(4, 4);
  tft.print("ST7735, black tab");
  tft.fillRect(20, 40, 88, 60, ST77XX_BLUE);
}

void loop() {}

Adafruit_ST7735.h is Mokxi's own, on the same calls as upstream. The bus is software SPI on the board's SPI pins, so a full-screen fill is slow on an Uno: draw what moves.

Common mistakes

initR for the wrong tab. Wiring SDA to the board's I2C pin because of its name. A0 left unconnected, which leaves every byte a command.

See it in action

Two color screens at /templates drives this panel and an ST7789 from one Uno. Set the ST7735's tab to green without changing the sketch, and look at the edges.