Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

instructables

TFT Animated Eyes

by Bodmer

This project uses low cost parts to create a pair of animated eyes on TFT screens. The project is based on the
Adafruit "Uncanny Eyes" project.

The two ST7735 128x128 pixel displays and the ESP32 board can typically bought online for around $10 total.

The software running on the ESP32 is an Arduino sketch, this is supported by the TFT_eSPI graphics library. The
sketch is an example provided within the TFT_eSPI library.

Other processors can also be used such as ESP8266 and STM32 boards. The ESP32 and STM32 processors can use
"Direct Memory Access" to transfer the images to the screen, this improves performance (aka frame rate). The
sketch uses a signi cant amount of RAM and FLASH program memory so bear this in mind when choosing a
processor.

Supplies:

The project, as described, uses:

Two ST7735 1.4" 128x128 TFT displays with 4 wire SPI interface
One ESP32 processor board
Breadboard and wires
Arduino IDE
TFT_eSPI library version 2.3.4 or later

Step 1: Performance

TFT Animated Eyes: Page 1


Choose which processor you are going to use. The ST7735 type displays can typically operate reliably
with SPI clock rates up to 27MHz. Other displays may
Typical rendering performances (fps = frames per operate at higher rates, however 27MHz gives a good
second) for an eye are dependant on the processor, performance.
the SPI clock rate and whether DMA is employed. The
ESP8266 gives the lowest frame rate but the eye
movement is still quite uid.

Step 2: Software Environment

The Arduino IDE is used to compile and upload the sketch to the ESP32. This is a relatively advanced project, so it is
suggested that you get the Arduino IDE up and running with the simpler examples to become familiar with the
environment.

The ESP32 board package must be loaded into the IDE if you are using that processor. For STM32 boards use the
o cial stm32duino package.

The TFT_eSPI graphics library can be loaded via the Arduino IDE's library manager.

The TFT_eSPI library provides 2 examples for eye animation:

Animated_Eyes_1 is an example for a single display (240 x 320 pixels minimum)


Animated_Eyes_2 is an example for two displays

This project uses the second sketch example.

If you are already a TFT_eSPI library user and have a 240x320 (or larger) display operating correctly then the
Animated_Eyes_1 will run without modi cation and display two animated eyes on a single screen.

TFT Animated Eyes: Page 2


Step 3: Display Connections

The prototype was built by plugging the ESP32 and The TFT_eSPI library uses "user_setup" les to de ne
displays into breadboards and using jumper wires. all the parameters for the display, processor and
This is convenient for initial experimentation but is interfaces, for the Animated_Eyes_2 sketch the
prone to poor connection especially if moved about. It "Setup47_ST7735.h" le was used with the wiring as
the eyes are to be used as part of a costume then shown above.
soldering all connections is recommended.
The displays used for testing were 128x128 ST7735
Normally the TFT chip select line for a single display is displays, the TFT_eSPI library setup le may need to
de ned within a user_setup le of the TFT_eSPI be changed as these displays come in many
library, however when using the library with two con guration variants.
displays the chip selects must be controlled by the
sketch, thus you must NOT de ne the TFT_CS pin in When it is all programmed and running the it can be
the TFT_eSPI library setup les. Instead, the chip unplugged from a computer and powered from a
selects (CS) must be de ned in the "con g.h" tab of phone charger battery pack that has a USB output.
the Animated_Eyes_2 sketch.

TFT Animated Eyes: Page 3

You might also like