Arduino: serial terminal on TFT display

This page presents a terminal that displays each character on a 2.8 inch TFT touch screen. The user send a character via USB (serial), the Arduino read the character and display the character on the screen. This page has been tested with the following versions (software and hardware):

Source code

The following source code assume the TFT library is loaded in the Arduino IDE.

// Small TFT terminal
// Display each character sent through the USB
// Support only new line (\n)
#include <SPI.h>
#include <stdint.h>
#include <TFTv2.h>

// Coordinates of the cursor
INT16U x=0;
INT16U y=0;

// Clear terminal
void tftClearTerminal()
  // Display a black rectangle in the terminal body 
  Tft.fillScreen(0, 230, 0, 320, BLACK);  

// Increase Y (new line)
// If cursor is at the bottom of the display, 
// Clear terminal to start a new page
void increase_Y()
  // Increase Y and check if last line
  if (++y>22)
      // Clear terminal (new page)

// Increase Y (next char)
// If cursor is a end of line, 
// jump to a new line
void increase_X()
  // Increase X and check if end of line
  if (++x>31) 
    // New line

// Display a char
void tftPutchar(char c)
  // Create an string for displaying the char
  char string[2];

  // New line ?
  if (c=='\n')
    // Display char
    Tft.drawString(string, x*10, 220-y*10, 1, WHITE, LANDSCAPE);

// Display terminal header (top blue banner)
void tftDisplayHeader()
  Tft.fillScreen(230, 240, 0, 320, BLUE);
  Tft.drawString("TFTerminal -", 0, 230, 1, WHITE, LANDSCAPE);

void setup()
  // Turn on the background light

  // Init TFT library

  // Display header and clear terminal

  // Initialize USB serial


void loop()
  // If a new char is available on serial link, 
  // Display the char
  if (Serial.available())

    // Uncomment for echoing


Test the terminal

You can test the terminal with the Arduino IDE. Specify 115200 bauds and NewLine.

On Linux, you can also use cu:

sudo apt-install cu
cu -l /dev/ttyACM0 -s 115200

Type ~. to exit the terminal. To use cu, you'll have to replace \n by \r in the source code for new line.

Seeeduino / Arduino terminal on TFT touch screen

About Seeed Studio

The hardware presented on this page was kindly donated by Seeed.

Seeed is the IoT hardware enabler providing services over 10 years that empower makers to realize their projects and products. Seeed offers a wide array of hardware platforms and sensor modules ready to be integrated with existing IoT platforms and one-stop PCB production and cheap pcb assembly. Seeed Studio provides a wide selection of electronic parts including Arduino, Raspberry Pi and many different development board platforms. Especially the Grove System helps engineers and makers to avoid jumper wires problems. Seeed Studio has developed more than 280 Grove modules covering a wide range of applications that can fulfill a variety of needs.


Arduino source code and TFT library can be downloaded here:

See also

Last update : 12/26/2019