Built-in project · Arduino Uno R3

Two color screens on an Arduino Uno

An ST7735 and an ST7789 on one Uno: the same command set, different glass. The ST7789 has no chip select, so it has pins of its own. The whole build, an Arduino Uno and 2 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

AdvancedRuns in your browser. Free, and no account needed.

Two color screens · Arduino Uno R3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// Two color screens: a 1.8 inch ST7735 and a 1.3 inch ST7789.
//
//   ST7735   SCK -> 13   SDA -> 11   CS -> 10   A0 -> 9   RESET -> 8   LED -> 5 V
//   ST7789   SCL -> A1   SDA -> A0   DC -> 7    RES -> 6  BLK -> 5 V   CS unwired
//
// Both chips speak the same command set as the ILI9341: a column window, a row
// window, then pixels, with DC saying which bytes are commands. What differs
// is the glass. The ST7789's memory is 240x320 and this panel shows 240x240 of
// it, so rotations that count rows from the bottom start at row 80; and its
// IPS glass shows colors inverted until INVON, which init() sends.
//
// The ST7789 is wired the way the 1.3 inch board comes: no chip select, so it
// listens to every clock on its pins. That is why it has pins of its own here
// (the five-argument constructor is software SPI on any pins). On the ST7735's
// bus it would take that panel's bytes as its own.
//
// Every pixel goes out bit by bit, so an Uno draws a small square quickly and
// a whole screen slowly: draw what moves.

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

Adafruit_ST7735 small(10, 9, 8);
Adafruit_ST7789 square(-1, 7, A0, A1, 6);  // no CS; DC, SDA, SCL, RES

void setup() {
  small.initR(INITR_BLACKTAB);
  small.fillScreen(ST77XX_BLACK);
  small.setTextColor(ST77XX_GREEN);
  small.setCursor(4, 4);
  small.print("ST7735 128X160");

  square.init(240, 240, SPI_MODE3);
  square.setRotation(2);
  square.fillRect(0, 0, 240, 40, ST77XX_BLUE);
  square.setTextColor(ST77XX_WHITE);
  square.setTextSize(2);
  square.setCursor(8, 12);
  square.print("ST7789 IPS");
}

void loop() {
  // A block that walks around each screen, in a color that changes as it goes.
  static uint8_t step = 0;
  uint16_t colour = Adafruit_ST7789::color565((uint8_t)(step * 16), 255 - step * 16, 128);
  small.fillRect((int16_t)(8 + (step % 8) * 14), 40, 12, 12, colour);
  square.fillRect((int16_t)(10 + (step % 8) * 28), 120, 24, 24, colour);
  step = (uint8_t)((step + 1) % 16);
  delay(100);
}

Parts list

4 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

11 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Arduino Uno R3 pin 13; TFT display, 1.8 inch ST7735 pin SCK
  • Arduino Uno R3 pin 11; TFT display, 1.8 inch ST7735 pin SDA
  • Arduino Uno R3 pin 10; TFT display, 1.8 inch ST7735 pin CS
  • Arduino Uno R3 pin 9; TFT display, 1.8 inch ST7735 pin A0
  • Arduino Uno R3 pin 8; TFT display, 1.8 inch ST7735 pin RESET
  • Arduino Uno R3 pin 7; IPS display, ST7789 pin DC
  • Arduino Uno R3 pin 6; IPS display, ST7789 pin RES
  • Arduino Uno R3 pin 5V; TFT display, 1.8 inch ST7735 pin VCC; TFT display, 1.8 inch ST7735 pin LED; IPS display, ST7789 pin VCC; IPS display, ST7789 pin BLK
  • Ground: Arduino Uno R3 pin GND; TFT display, 1.8 inch ST7735 pin GND; IPS display, ST7789 pin GND
  • Arduino Uno R3 pin A0; IPS display, ST7789 pin SDA
  • Arduino Uno R3 pin A1; IPS display, ST7789 pin SCL

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.