Arduino Function: TFT Constructor


The base class for drawing to the Arduino TFT screen. Use this to create an named instance of the TFT class to refer to in your sketch. if using the Arduino Explora, you do not need to call this, all references to the screen are handled through EsploraTFT.


TFT(cs, dc, rst); for using hardware SPI
TFT(cs, dc, mosi, sclk, rst); for use on any pins


  • cs : int, pin for chip select
  • dc : int, pin used for
  • rst : int, pin used for reset
  • mosi : int, pin used for MOSI communication when not using hardware SPI
  • sclk : int, pin used for the shared clock, when not using hardware SPI


#include <SPI.h>
#include <TFT.h> // Arduino LCD library

#define cs 10
#define dc 9
#define rst 8

TFT screen = TFT(cs, dc, rst);

void setup() {
// initialize the screen

// make the background black

// set the stroke color to white

// turn off fill coloring

// draw a rectangle in the center of screen
screen.line(screen.width()/2-5, screen.height()/2-5, 10, 10);

void loop() {}

Based on the reference originally written by Arduino Community, and