Arduino

Reference Language | Libraries | Comparison | Changes

## TFT LCD library

The TFT library is included with Arduino IDE 1.0.5 and later. This library enables an Arduino board to communicate with the Arduino TFT LCD screen. It simplifies the process for drawing shapes, lines, images, and text to the screen. The Arduino TFT library extends the Adafruit GFX, and Adafruit ST7735 libraries that it is based on. The GFX library is responsible for the drawing routines, while the ST7735 library is specific to the screen on the Arduino TFT. The Arduino specific additions were designed to work as similarly to the Processing API as possible.

Onboard the screen is a SD card slot, which can be used through the SD library.

The TFT library relies on the SPI library for communication with the screen and SD card, and needs to be included in all sketches.

### Using the library

The screen can be configured for use in two ways. One is to use an Arduino's hardware SPI interface. The other is to declare all the pins manually. There is no difference in the functionality of the screen between the two methods, but using hardware SPI is significantly faster.

If you plan on using the SD card on the TFT module, you must use hardware SPI. All examples in the library are written for hardware SPI use.

If using hardware SPI with the Uno, you only need to declare the CS, DC, and RESET pins, as MOSI (pin 11) and SCLK (pin 13) are already defined.

#define CS 10
#define DC 9
#define RESET 8
TFT myScreen = TFT(CS, DC, RESET);
[Get Code]

To use hardware SPI with the Leonardo, you declare the pins like so :

#define CS 7
#define DC 0
#define RESET 1
TFT myScreen = TFT(CS, DC, RESET);
[Get Code]

When not using hardware SPI, you can use any available pins, but you must declare the MOSI and SCLK pins in addition to CD, DC, and RESET.

#define SCLK 4
#define MOSI 5
#define CS 6
#define DC 7
#define RESET 8
TFT myScreen = TFT(CS, DC, MOSI, SCLK, RESET);
[Get Code]

### Using the Arduino Esplora and the TFT library

As the Arduino Esplora has a socket designed for the TFT, and the pins for using the screen are fixed, an Esplora only object is created when targeting sketches for that board. You can reference the screen attached to an Esplora through `EsploraTFT`.

### Similarities to Processing

Processing is an open source software environment used by designers, artists, and students. The main output of Processing is a graphic window on a computer or browser. The Arduino TFT library has made the calls for drawing primitives and text to the screen as "Processing-like" as possible to ensure a smooth transition between the two environments.

### Examples

There are two groups of examples for the TFT. There are examples specific to the Arduino Esplora, and examples that are designed for boards like the Uno or Leonardo. It should be easy to translate from one to the other once you've gotten a handle on the library and its functionality.

ARDUINO

- TFT Bitmap Logo: Read an image file from a micro-SD card and draw it at random locations.
- TFT Color Picker: With three sensors, change the color of the TFT screen.
- TFT Display Text: Read the value of a sensor and print it on the screen.
- TFT Etch a Sketch: An Arduino version of the classic Etch-a-Sketch.
- TFT Graph: Graph the values from a variable resistor to the TFT.
- TFT Pong: An Arduino implementation of the classic game.

ESPLORA

- Esplora TFT Bitmap Logo: Use the Esplora as a controller to play a kart racing game.
- Esplora TFT Color Picker: Using the joystick and slider, change the color of the TFT screen.
- Esplora TFT Etch a Sketch: An Esplora implementation of the classic Etch-a-Sketch.
- Esplora TFT Graph: Graph the values from the light sensor to the TFT.
- Esplora TFT Horizon: Draw an artificial horizon line based on the tilt from the accelerometer.
- Esplora TFT Pong: A basic implementation of the classic game.
- Esplora TFT Temp: Check the temperature with the onboard sensor and display it on screen.

For additional information on the TFT screen, see the Getting Started page and the hardware page.

#### TFT

- TFT
- EsploraTFT

- begin()
- background()
- stroke()
- noStroke()
- fill()
- noFill()
- text()
- setTextSize()
- begin()
- point()
- line()
- rect()
- width()
- height()
- circle()
- image()
- loadImage()

- PImage
- PImage.height()
- PImage.width()
- PImage.isValid()

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

### Share

### This link has expired.
Please re-subscribe to our Newsletters.

### Subscribe to our Newsletters

Email

Please enter a valid email to subscribe

Arduino Newsletter
Arduino Store Newsletter

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy

###### Newsletter

- ©2015 Arduino
- Copyright Notice
- Contact us
- About us
- Careers