TFT flashes when using Arduino code with Pico & ST7735

hi all,

I'm in need of some help with a wierd but basic issue on a device I am making for a disabled scooter. I built a circuit and wrote some code using an arduino but ran into memory and storage problems, so I moved the circuit to a Pico and tried the Arduino code in the Arduino IDE. The LCD code didn't work so I did the usual and cut it down to basics.
The arduino and Pico connect to various modules, but the one that I'm having an issue with is the ST7735 TFT.
If you run the below code it works fine, but if you then uncomment the tft.print("Test"); statement the whole display flashes rapidly.

I've swapped the screen, reinstalled and tried alternative libraries. I've also swapped SPI pins.
The screen works great on the Arduino and works when the print statement is not active so it's likely not the screen unless it has some issue that only shows itself on the Pico. It seems like the SPI bus is running too fast or not being initialised properly but I'm having difficulty narrowing it down.

Your help would be much appreciated.

ST7735 Rpi Pico

SCK GP10

SDA(MOSI) GP11

DC GP7

RESET GP8

CS GP9

GND GND

LED / PWR 3V3


// Load the Libraries
#include <Adafruit_GFX.h>               // Adafruit LCD Graphics library
#include <Adafruit_ST7735.h>            // ST7735 LCD Display library
#include <SPI.h>                        // Arduino SPI and I2C library

// pin definition for the 1.8", 128x160 ST7735 LCD Display on Raspberry Pico
// These can be connected to any GP Pin not in use
#define TFT_CS      9       // using SPI1 CSn
#define TFT_RST     8
#define TFT_DC      7

// Used for SPI connectivity on SPI1
#define TFT_SCK     10
#define TFT_MOSI    11
// #define TFT_MISO         // not used with this display

// Setup the ST7735 LCD Display and variables
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCK, TFT_RST);
// Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

int textxoffset = 5;     // move 5 pixels across to avoid the box
int textyoffset = 7;     // move 7 pixels down to avoid the box

int tft_line1 = 0;


void setup() {
  // put your setup code here, to run once:
  tft.initR(INITR_BLACKTAB);                          // initialize a ST7735S chip, black tab
  tft.fillScreen(ST7735_BLACK);                       // Fill the screen with Black
  tft.setRotation(1);                                 // Set rotation to Portrait mode (set to '1' for Landscape)
  tft.setTextWrap(false);                             // By default long lines of text are NOT wrapped at the end of the line, set to 'TRUE' for wrapping the text

  // Draw the 1.8" LED display layout using 24 bit colour (limitation of the ST7735S library)
  // tft.drawRect(0, 0, 159, 128, ST7735_CYAN);       // Draw a Rectangle  x,y, across, down for the Colour Values
  tft.drawRoundRect(0, 0, 83, 31, 10, ST7735_CYAN);   // Draw a Rectangle  x,y, across, down with corner & Colour Values
  tft.drawRoundRect(0, 35, 160, 93, 10, ST7735_CYAN); // Draw a Rectangle  x,y, across, down with corner & Colour Values
  tft.drawLine(80, 65, 80, 110, ST7735_CYAN);         // Draw a mid-line  x1,y1, x2, y2 for the Colour Values


  tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
  tft.setTextSize(1);                                 // Set the text size to 1
  tft.setCursor(textxoffset + 54,textyoffset + 1);
//   tft.print("Test");


}

void loop() {
  // put your main code here, to run repeatedly:

}

Your code with "test" works in the wokwi simulator. (I changed the color of the lines only).

Thanks very much for your reply, I've not tried it with any simulators.
Was that using an arduino or a Pico as the MCU?

Arduino Nano

Thanks for your help.
My original code was written on and works well on the nano, but when porting to the Pico due to the nano's limitations it seems that the libraries aren't fully compatible (including the ST7735 I am using). I'm trying to find a new ST7735 library that works with the Pico now as I think that's the issue I'm having.

Well, I figured it out after a LOT of messing about.
With the Arduino you only need to connect the LCD line to the 3.3v for power, while the Pico requires BOTH the 3.3v AND the 5v line to be connected!!!
As soon as you do this it works like it does on the Arduino board.

@xfpd thanks for your replies.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.