Multiple ST7735 displays with Arduino Nano

I am trying to write information to two ST7735 displays (1.8" COLOUR TFT 128x160 Display ST7735 SPI Arduino ESP Pi FREE 1st Class Post | eBay) independantly, ie one to show text and the other to show graphics, from an Arduino Nano.

I have been able to write to each display separately, but when connecting the other display, both screens remain white.
From reading other forum posts it seems I am able to connect both the displays to the MOSI (D11), SCK (D13), and RST pins on the Nano, but with separate CS pins. In this case my CS pins are D8 and D10. However the displays clearly seem to interfere with one-another.

Any help would be greatly appreciated! :slight_smile:

My code is as follows:

#include <Adafruit_ST77xx.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include "Fonts/FreeSans12pt7b.h"

#define GREEN 0x07E0
// ST7789 TFT module connections
#define TFT_CS    10  // define chip select pin
#define TFT_CS1    8  // define chip select pin
#define TFT_DC     9  // define data/command pin
#define TFT_RST    -1  // define reset pin, or set to -1 and connect to Arduino RESET pin

// Initialize Adafruit ST7789 TFT library
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,TFT_DC, TFT_RST);
Adafruit_ST7735 tft1 = Adafruit_ST7735(TFT_CS1,TFT_DC,TFT_RST);

const int input_pin = 4;

int img_count=1;
int ms = 1000;
int img_temp ;

int16_t sx= tft.width();
const int block = (sx/9);
int x,y=0;
int r=10;
int t=block*1.5;
int spx=block*2;
int spy=block*2;

int messx = 10;
int messy = tft1.height()/2;
int num_sz = 3;
int txt_sz = 3;
const GFXfont *f = &FreeSans12pt7b;



void setup() 
  {

    Serial.begin(9600);
    tft.initR(INITR_GREENTAB);    // Init ST7789 display 240x240 pixel
    tft1.initR(INITR_GREENTAB);    // Init ST7789 display 240x240 pixel
    
    tft.setRotation(1);
    tft1.setRotation(1);
    
    tft.invertDisplay(false);
    tft1.invertDisplay(false);
    
    tft.fillScreen(ST7735_BLACK);
    tft1.fillScreen(ST7735_BLACK);
    
    pinMode(input_pin, INPUT);
  }


void loop() {

  if (digitalRead(input_pin)==HIGH)
    {
      img_count ++;
    }

  if (img_temp==img_count)
    return;
  
  switch  (img_count){
    case 0:
      img1();
      break;
    case 1:
      img2();
      break;
    case 2:
      img3();
      img_count=-1;
      break;
    } 
   img_temp = img_count;
    while(digitalRead(input_pin)==HIGH)
    {}

  delay(ms);
}

void showmsgXY(int x, int y, int sz, const GFXfont *f, const char *msg)
  {
  int16_t x1, y1;
  uint16_t wid, ht;
  tft1.setFont(f);
  tft1.setCursor(x, y);
  tft1.setTextColor(GREEN);
  tft1.setTextSize(sz);
  tft1.setTextWrap(true);
  tft1.print(msg);
  }

void img1()
  {
  tft.fillScreen(ST77XX_BLACK);
  tft.fillRoundRect(spx,spy,t,block*5,r,GREEN); //vertical rectangle
  //fillRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, uint8_t R , uint16_t t)
  tft.fillRoundRect(spx,spy,block*4,t,r,GREEN); //horizontal rectangle
  tft.fillTriangle(5*block,block,5*block,4.5*block,8*block,spy+0.5*t,GREEN); 
  //drawTriangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3,// uint16_t t)
 
  tft1.fillScreen(ST77XX_BLACK);
  showmsgXY(messx, messy, num_sz, f, "20");
  tft1.setTextSize(txt_sz);
  tft1.print("m");
}

void img2(){
  tft.fillScreen(ST77XX_BLACK);
  tft.fillRoundRect(sx-(spx+(t)),spy,t,block*5,r,GREEN); //vertical rectangle
  //fillRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, uint8_t R , uint16_t t)
  tft.fillRoundRect(sx-(spx+(block*4)),spy,block*4,t,r,GREEN); //horizontal rectangle
  tft.fillTriangle(sx-(5*block),block,sx-(5*block),4.5*block,sx-(8*block),2.75*block,GREEN); 
  //drawTriangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3,// uint16_t t)
  
  tft1.fillScreen(ST77XX_BLACK);
  showmsgXY(messx, messy, num_sz, f, "30");
  tft1.setTextSize(txt_sz);
  tft1.print("m");//*/
}

void img3(){
  tft.fillScreen(ST77XX_BLACK);
  tft.fillRoundRect(sx/2-(0.5*t),spy+(t-r),t,block*5,r,GREEN); //vertical rectangle
  //fillRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, uint8_t R , uint16_t t)
  tft.fillTriangle(sx/2-spx,spy+t, sx/2+spx, spy+t, sx/2, spy-block,GREEN); 

  tft1.fillScreen(ST77XX_BLACK);
  showmsgXY(messx, messy, num_sz, f, "60");
  tft1.setTextSize(txt_sz);
  tft1.print("m");//*/
}

ST7735_dual_combi.ino (3.66 KB)