Displaying Text on a 1.54″ SPI Color LCD (240×240) Tutorial

Description: A 1.54″ SPI Color LCD (240×240) connected to an Arduino Nano has its background colors and its displayed text changed every few seconds.

Displaying Text on a 1.54 SPI Color LCD

Notes: In order to change the background color to a custom color, an RGB565 hex color code needs to be inserted inside the round brackets in screen.fillScreen(); code below, like this: screen.fillScreen(0x200A); An online RGB565 Color Picker, like barth-dev.de, can be useful to find a specific color.

Supplies:

1 – Breadboard 400 Points
1 – Arduino Nano
1 – 1.54″ SPI Colour Square LCD (240×240) by Pimoroni

Arduino Code:

#include “DFRobot_GDL.h”

#define TFT_DC 7
#define TFT_CS 10
#define TFT_RST 9

DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);

void setup() {

  Serial.begin(115200);
  screen.begin();

}

void loop() {

  screen.setTextSize(1);
  screen.fillScreen(COLOR_RGB565_BLUE); //Set screen color
  screen.setFont(&FreeMono18pt7b); //Set font to FreeMono12pt7b
  screen.setCursor(/*x=*/70,/*y=*/120);
  screen.setTextColor(COLOR_RGB565_LGRAY); //Set text color
  screen.setTextWrap(true); //Set to text auto-wrap mode, true=Auto-wrap, false=No auto-wrap
  screen.print(“Visit”);
  delay(2000);

  screen.fillScreen(COLOR_RGB565_BLACK);
  screen.setCursor(/*x=*/5,/*y=*/120);
  screen.print(“Our Website”);
  delay(2000);

  screen.setTextSize(1);
  screen.fillScreen(0x200A);
  screen.setFont(&FreeMono9pt7b);
  screen.setCursor(/*x=*/10,/*y=*/120);
  screen.print(“tropicalengineer.com”);
  delay(3000);

}

Leave a Comment

+ 79 = 81