Example Code of Showing Character for Arduino

Last revision 2026/02/04

This guide provides instructions for displaying custom text on a 2.2-inch screen using Arduino, including setting coordinates, color customization, and font size adjustments. It highlights the necessity of an external GT30L font chip for displaying Chinese characters.

Introduction

The function of the program: taking the centre point of the 2.2”screen as the starting point(note: the graphic display coordinates and the text display coordinates are two different coordinates, the centre point of the graphic display coordinates is (64, 64) while that of the later one is (0, 0)), display a character string ”fire” with red text background box, white font and the size of the font 2 on the screen. The formal parameter size of the function to set font size tft.setTextSize (uint8_t size) should be greater than 0 and the text out of the screen cannot be displayed.

Sample Code

#include "DFRobot_ST7687S_Latch.h"

#ifdef __AVR__
uint8_t pin_cs = 3, pin_rs = 5, pin_wr = 6, pin_lck = 7;
#else
uint8_t pin_cs = D3, pin_rs = D5, pin_wr = D6, pin_lck = D7;
#endif

DFRobot_ST7687S_Latch tft(pin_cs, pin_rs, pin_wr, pin_lck);

void setup(void)
{
  Serial.begin(115200);
  tft.begin();
  tft.fillScreen(DISPLAY_BLACK);
}

void loop(void)
{
  tft.setCursor(64, 64);
  tft.setTextBackground(DISPLAY_RED);  //set text background as black
  tft.setTextColor(DISPLAY_WHITE);  //set text color as white
  tft.setTextSize(2);  //2 * text size, default text size: 6 * 8
  tft.print("fire");
  delay(1000);
}

Result


Note: you need to connect an external font chip GT30L to display Chinese characters as there is no font chip in the 2.2" display.

Was this article helpful?

TOP