# 1.8" TFT Display Breakout and Shield

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/019/552/medium800/lcds___displays_358_ORIG.jpg?1409943847)

This tutorial is for our 1.8" diagonal TFT display. It comes packaged as a breakout or as an Arduino shield. Both styles have a microSD interface for storing files and images. These are both great ways to add a small, colorful and bright display to any project. Since the display uses 4-wire SPI to communicate and has its own pixel-addressable frame buffer, it requires little memory and only a few pins. This makes it ideal for use with small microcontrollers.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/636/medium800/arduino_compatibles_1.8_TFT_back_EYESPI_connector.jpg?1674599279)

This display breakout comes with an EYESPI connector! This 18-pin 0.5mm pitch FPC connector has a flip-top connector for using a flex cable to hook up your display. It enables you to avoid soldering and get your display up off of the breadboard! Consider it a sort of "STEMMA QT for displays" - a way to quickly connect and extend display wiring that uses a lot of SPI pins. It also allows for communicating with displays over longer distances. The [EYESPI flex cables](https://www.adafruit.com/?q=eyespi+cable&sort=BestMatch) are available in multiple lengths to suit any project. This is especially useful for projects where you want your display mounted separate from your microcontroller.

The shield version plugs directly into an Arduino with no wiring required. The breakout version can be used with every kind of microcontroller.

![](https://cdn-learn.adafruit.com/assets/assets/000/008/415/medium800/lcds___displays_2013_05_02_IMG_1736-1024.jpg?1396864921)

The 1.8" display has 128x160 color pixels. Unlike the low cost "Nokia 6110" and similar LCD displays, which are CSTN type and thus have poor color and slow refresh, this display is a true TFT! The TFT driver (ST7735R) can display full 18-bit color (262,144 shades!). And the LCD will always come with the same driver chip so there's no worries that your code will not work from one to the other.  
  
Both boards have the TFT soldered on (it uses a delicate flex-circuit connector) as well as a ultra-low-dropout 3.3V regulator and a 3/5V level shifter so you can use it with 3.3V **or** 5V power and logic. These also include a microSD card holder so you can easily load full color bitmaps from a FAT16/FAT32 formatted microSD card. And on the Shield version, we've added a nifty 5-way joystick navigation switch!  
  
**You can pick up one of these displays in the Adafruit shop!**  
 [1.8" 18-bit color TFT breakout](http://www.adafruit.com/products/358 "Link: http://www.adafruit.com/products/358")  
[1.8" 18-bit Color TFT Shield](http://www.adafruit.com/products/802 "Link: http://www.adafruit.com/products/802")

# 1.8" TFT Display Breakout and Shield

## 1.8" TFT Breakout

![](https://cdn-learn.adafruit.com/assets/assets/000/019/554/medium800/lcds___displays_358scale_ORIG.jpg?1409943920)

This lovely little display breakout is the best way to add a small, colorful and bright display to any project. Since the display uses 4-wire SPI to communicate and has its own pixel-addressable frame buffer, it can be used with every kind of microcontroller. Even a very small one with low memory and few pins available!

The 1.8" display has 128x160 color pixels. Unlike the low cost "Nokia 6110" and similar LCD displays, which are CSTN type and thus have poor color and slow refresh, this display is a true TFT! The TFT driver (ST7735R) can display full 18-bit color (262,144 shades!). And the LCD will always come with the same driver chip so there's no worries that your code will not work from one to the other.

The breakout has the TFT display soldered on (it uses a delicate flex-circuit connector) as well as a ultra-low-dropout 3.3V regulator and a 3/5V level shifter so you can use it with 3.3V or 5V power and logic. We also had a little space so we placed a microSD card holder so you can easily load full color bitmaps from a FAT16/FAT32 formatted microSD card. The microSD card is not included, [but you can pick one up here](http://www.adafruit.com/products/102).

This display breakout also features an&nbsp;[18-pin "EYESPI" standard FPC connector](https://www.adafruit.com/?q=eyespi&sort=BestMatch)&nbsp;with flip-top connector.&nbsp;[You can use an 18-pin 0.5mm pitch FPC cable](https://www.adafruit.com/product/5239)&nbsp;to connect to all the GPIO pins&nbsp;for when you want to skip the soldering.

# 1.8" TFT Display Breakout and Shield

## Pinouts

![](https://cdn-learn.adafruit.com/assets/assets/000/117/639/medium800/arduino_compatibles_1.8_TFT_back_original.jpg?1674600084)

![](https://cdn-learn.adafruit.com/assets/assets/000/117/638/medium800/arduino_compatibles_1.8_TFT_back_EYESPI_connector.jpg?1674600042)

## EYESPI

This display comes with an EYESPI connector, which is an 18pin 0.5mm pitch connector that allows you to use a flex cable to connect your display to your microcontroller. For more details, visit the [EYESPI page](https://learn.adafruit.com/1-8-tft-display/eyespi).

This color display uses SPI to receive image data. That means you need at least 4 pins - clock, data in, tft cs and d/c. If you'd like to have SD card usage too, add another 2 pins - data out and card cs. However, there's a couple other pins you may want to use, lets go thru them all!

- **Lite** - this is the PWM input for the backlight control. Connect to 3-5VDC to turn on the backlight. Connect to ground to turn it off. Or, you can PWM at any frequency.
- **MISO** - this is the SPI Microcontroller In Serial Out pin, its used for the SD card. It isn't used for the TFT display which is write-only
- **SCLK** - this is the SPI clock input pin
- **MOSI** - this is the SPI Microcontroller Out Serial In pin, it is used to send data from the microcontroller to the SD card and/or TFT
- **TFT\_CS** - this is the TFT SPI chip select pin
- **Card CS -** this is the SD card chip select, used if you want to read from the SD card.
- **D/C** - this is the TFT SPI data or command selector pin
- **RST** - this is the TFT reset pin. Connect to ground to reset the TFT! Its best to have this pin controlled by the library so the display is reset cleanly, but you can also connect it to the Arduino Reset pin, which works for most cases.
- **Vcc** - this is the power pin, connect to 3-5VDC - it has reverse polarity protection but try to wire it right!
- **GND** - this is the power and signal ground pin

For the level shifter we use the [CD74HC4050](http://www.ti.com/product/CD74HC4050/) which has a typical propagation delay of ~10ns

# 1.8" TFT Display Breakout and Shield

## EYESPI

![](https://cdn-learn.adafruit.com/assets/assets/000/117/633/medium800/arduino_compatibles_1.8_TFT_EYESPI_connected.jpg?1674596619)

This display now comes with an **EYESPI connector**. This connector allows you to connect your display without soldering. There are [EYESPI cables](https://www.adafruit.com/?q=eyespi+cable&sort=BestMatch) available in multiple lengths, which means you can find one to fit any project. This is especially useful if your project requires the display to be freestanding, and not tied directly into a breadboard. Inspired by the popularity of STEMMA QT, it provides plug-n-play for displays!

## The EYESPI Connector and Cables

The EYESPI connector is an 18 pin 0.5mm pitch FPC connector with a flip-top tab for locking in the associated flex cable. It is designed to allow you to connect a display, without needing to solder headers or wires to the display.

The EYESPI connector location on this display is indicated below.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/634/medium800/arduino_compatibles_1.8_TFT_back_EYESPI_connector_location.jpg?1674596704)

The EYESPI cables are 18 pin 0.5mm pitch flex cables. They are ~9.6mm wide, and designed to fit perfectly into the EYESPI connector. Adafruit currently offers EYESPI cables in three different lengths: [50mm](https://www.adafruit.com/product/5462), [100mm](https://www.adafruit.com/product/5239), and [200mm](https://www.adafruit.com/product/5240).

Warning: 

## Wiring Your EYESPI Display

Wiring your EYESPI display to a microcontroller via the EYESPI connector requires the EYESPI breakout board and an EYESPI cable.

### Adafruit EYESPI Breakout Board - 18 Pin FPC Connector

[Adafruit EYESPI Breakout Board - 18 Pin FPC Connector](https://www.adafruit.com/product/5613)
Our most recent [display breakouts have come with a new feature:&nbsp;an 18-pin "EYE SPI" standard FPC connector with flip-top connector](https://www.adafruit.com/?q=eyespi&sort=BestMatch). This is intended to be a sort-of "<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/5613)
[Related Guides to the Product](https://learn.adafruit.com/products/5613/guides)
![Overhead video of a 1.9" TFT display connected via 18-pin FPC ribbon cable to a square-shaped microcontroller on a breadboard. The TFT plays an animated boot-up demo.](https://cdn-shop.adafruit.com/product-videos/640x480/5613-06.jpg)

### EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type

[EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type](https://www.adafruit.com/product/5239)
Connect this to that when a 18-pin FPC connector is needed. This 25 cm long cable is made of a flexible PCB. It's A-B style which means that pin one on one side will match with pin one on the other side. How handy!

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5239)
[Related Guides to the Product](https://learn.adafruit.com/products/5239/guides)
![Angled shot of a EYESPI Cable - 18 Pin 100mm long Flex PCB (FPC) A-B type. ](https://cdn-shop.adafruit.com/640x480/5239-00.jpg)

The following example shows how to connect the 1.8" TFT Display Breakout to a Feather RP2040 using the EYESPI breakout board.

Connect the following Feather pins to the associated EYESPI breakout pins:

- **breakout Vin** to **Feather 3.3V (red wire)**
- **breakout Lite** to **Feather 3.3V (yellow wire)**
- **breakout Gnd** to **Feather GND (black wire)**  
- **breakout SCK** to&nbsp; **Feather** **SCK (grey wire)**
- **breakout MISO** to&nbsp; **Feather** **MI (green wire)**  
- **breakout MOSI** to&nbsp; **Feather** **MO (purple wire)**  
- **breakout TCS** to **Feather D5 (blue wire)**
- **breakout DC** to **Feather D6 (orange wire)**
- **breakout RST** to **Feather D9 (cyan wire)**
- **breakout SDCS** to **Feather D10 (pink wire)**  

![arduino_compatibles_1.8_TFT_EYESPI_wiring_bb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/724/medium640/arduino_compatibles_1.8_TFT_EYESPI_wiring_bb.jpg?1674854359)

Finally, connect your **display EYESPI connector** to the **breakout EYESPI connector** using an **EYESPI cable**. For details on using the EYESPI connector properly, visit [Plugging in an EYESPI Cable](https://learn.adafruit.com/adafruit-eyespi-breakout-board/plugging-in-an-eyespi-cable).

## EYESPI Pins

Though there are 18 pins available on the EYESPI connector, many displays do not use all available pins. This display requires the following pins:

- **Vin** - This is the power pin. To power the board (and thus your display), connect to the same power as the logic level of your microcontroller, e.g. for a 3V micro like a Feather, use 3V, and for a 5V micro like an Arduino, use 5V.
- **Lite** - This is the PWM input for the backlight control. It is by default pulled high (backlight on), however, you can PWM at any frequency or pull down to turn the backlight off.
- **Gnd** - This is common ground for power and logic.&nbsp;
- **MISO** - This is the SPI MISO ( **M** icrocontroller **I** n / **S** erial **O** ut) pin. It's used for the SD card. It isn't used for the display because it's write-only. It is 3.3V logic out (but can be read by 5V logic).
- **MOSI** - This is the SPI MOSI ( **M** icrocontroller **O** ut / **S** erial **I** n) pin. It is used to send data from the microcontroller to the SD card and/or display.&nbsp;
- **SCK** - This is the SPI clock input pin.
- **TCS** - This is the TFT SPI chip select pin.
- **RST** - This is the display reset pin. Connecting to ground resets the display! It's best to have this pin controlled by the library so the display is reset cleanly, but you can also connect it to the microcontroller's Reset pin, which works for most cases. Often, there is an automatic-reset chip on the display which will reset it on power-up, making this connection unnecessary in that case.
- **DC** - This is the display SPI data/command selector pin.
- **SDCS** - This is the SD card chip select pin. This pin is required for communicating with the SD card holder onboard the connected display.

# 1.8" TFT Display Breakout and Shield

## Plugging in an EYESPI Cable

![](https://cdn-learn.adafruit.com/assets/assets/000/116/975/medium800/adafruit_products_edited_P1390328.jpg?1670356850)

You can connect an EYESPI compatible display to the EYESPI breakout board using an EYESPI cable. An EYESPI cable is an 18 pin flexible PCB (FPC). The FPC can only be connected properly in one orientation, so be sure to follow the steps below to ensure that your display and breakout are plugged in properly.

Each EYESPI cable has **blue stripes** on either end. On the other side of the cable, underneath the blue stripe, are the connector pins that make contact with the FPC connector pins on the display or breakout.

![adafruit_products_cableStripe.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/970/medium640thumb/adafruit_products_cableStripe.jpg?1670356463)

To begin inserting an EYESPI cable to an FPC connector, gently lift the FPC connector black latch up.&nbsp;

![adafruit_products_liftLatch.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/971/medium640thumb/adafruit_products_liftLatch.jpg?1670356608)

Then, insert the EYESPI cable into the open FPC connector by sliding the cable into the connector. You want to **see the blue stripe facing up towards you**. This inserts the cable pins into the FPC connector.

![adafruit_products_insertCable.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/972/medium640thumb/adafruit_products_insertCable.jpg?1670356741)

To secure the cable, lower the FPC connector latch onto the EYESPI cable.

![adafruit_products_lowerLatch.gif](https://cdn-learn.adafruit.com/assets/assets/000/116/973/medium640thumb/adafruit_products_lowerLatch.jpg?1670356793)

Repeat this process for the FPC connector on your display. Again, ensure that the **blue stripe** on either end of the cable is facing up.

![adafruit_products_edited_P1390333.jpg](https://cdn-learn.adafruit.com/assets/assets/000/116/974/medium640/adafruit_products_edited_P1390333.jpg?1670356806)

# 1.8" TFT Display Breakout and Shield

## Breakout Assembly

![](https://cdn-learn.adafruit.com/assets/assets/000/019/555/medium800/lcds___displays_358top_ORIG.jpg?1409944057)

## Prepare the header strip:

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - **long pins down**

![lcds___displays_header.jpg](https://cdn-learn.adafruit.com/assets/assets/000/019/556/medium640/lcds___displays_header.jpg?1409944088)

## Add the breakout board:

Place the breakout board over the pins so that the short pins poke through the breakout pads

![lcds___displays_place.jpg](https://cdn-learn.adafruit.com/assets/assets/000/019/557/medium640/lcds___displays_place.jpg?1409944108)

## And Solder!

Be sure to solder all pins for reliable electrical contact.  
  
_(For tips on soldering, be sure to check out our_ [_Guide to Excellent Soldering_](http://learn.adafruit.com/adafruit-guide-excellent-soldering)_)._

![lcds___displays_solder1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/019/558/medium640/lcds___displays_solder1.jpg?1409944128)

![lcds___displays_solder2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/019/559/medium640/lcds___displays_solder2.jpg?1409944155)

You're done! Check your solder joints visually and continue onto the next steps

![lcds___displays_done.jpg](https://cdn-learn.adafruit.com/assets/assets/000/019/560/medium640/lcds___displays_done.jpg?1409944169)

# 1.8" TFT Display Breakout and Shield

## Breakout Wiring & Test

There are two ways to wire up these displays - one is a more flexible method (you can use any pins on the Arduino) and the other is much faster (4-8x faster, but you are required to use the hardware SPI pins) We will begin by showing how to use the faster method, you can always change the pins later for flexible 'software SPI'

![](https://cdn-learn.adafruit.com/assets/assets/000/019/562/medium800/lcds___displays_spiwire.jpg?1409945098)

Wiring up the display in SPI mode is pretty easy as there's not that many pins! We'll be using hardware SPI, but you can also use software SPI (any pins) later. Start by connecting the power pins

- **3-5V Vin** connects to the Arduino **5V** pin - red wires
- **GND** connects to Arduino ground - black wires
- **CLK** connects to SPI clock. On Arduino Uno/Duemilanove/328-based, thats **Digital 13**. On Mega's, its **Digital 52** and on Leonardo/Due its **ICSP-3** ([See SPI Connections for more details](http://arduino.cc/en/Reference/SPI)) - this is the orange wire
- **MOSI** connects to SPI MOSI. On Arduino Uno/Duemilanove/328-based, thats **Digital 11**. On Mega's, its **Digital 51** and on Leonardo/Due its **ICSP-4** ([See SPI Connections for more details](http://arduino.cc/en/Reference/SPI "Link: http://arduino.cc/en/Reference/SPI")) - this is the white wire
- **CS** connects to our SPI Chip Select pin. We'll be using **Digital 10** but you can later change this to any pin - this is the yellow wire
- **RST** connects to our TFT reset pin. We'll be using **Digital 9** but you can later change this pin too - this is the blue wire
- **D/C** connects to our SPI data/command select pin. We'll be using **Digital 8** but you can later change this pin too - this is the green wire

# Install Adafruit ST7735 TFT Library

We have example code ready to go for use with these TFTs. It's written for Arduino, which should be portable to any microcontroller by adapting the C++ source.

_Three_ libraries need to be installed&nbsp;using the **Arduino Library Manager** …this is the preferred and modern way. From the Arduino “Sketch” menu, select “Include Library” then “Manage Libraries…”

![](https://cdn-learn.adafruit.com/assets/assets/000/065/251/medium800/arduino_compatibles_managelib.png?1541474290)

Search for and install the Adafruit GFX library:

![](https://cdn-learn.adafruit.com/assets/assets/000/065/252/medium800/arduino_compatibles_image.png?1541474525)

And the Adafruit ST7735 library:

![](https://cdn-learn.adafruit.com/assets/assets/000/065/253/medium800/arduino_compatibles_image.png?1541474578)

If using an older version of the Arduino IDE (pre-1.8.10), also locate and install the **Adafruit\_BusIO** library (newer versions do this automatically when using the Arduino Library Manager).

If this is all unfamiliar, we have a [tutorial introducing Arduino library concepts and installation](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use).  
  
Restart the IDE!

![](https://cdn-learn.adafruit.com/assets/assets/000/019/563/medium800/lcds___displays_gfxtest.png?1409945233)

After restarting the Arduino software, you should see a new **example** folder called **Adafruit\_ST7735** and inside, an example called **graphicstest**.

Now upload the sketch to your Arduino. You may need to press the Reset button to reset the arduino and TFT. You should see a collection of graphical tests draw out on the TFT.

![](https://cdn-learn.adafruit.com/assets/assets/000/019/564/medium800/lcds___displays_358demo1_ORIG.jpg?1409945263)

Once uploaded, the Arduino should perform all the test display procedures! If you're not seeing anything - first check if you have the backlight on, if the backlight is not lit something is wrong with the power/backlight wiring. If the backlight is lit but you see nothing on the display make sure you're using our suggested wiring.

# Changing Pins

Now that you have it working, there's a few things you can do to change around the pins.

If you're using Hardware SPI, the CLOCK and MOSI pins are 'fixed' and cant be changed. But you can change to software SPI, which is a bit slower, and that lets you pick any pins you like. Find these lines:

```
// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);


```

Comment out option 1, and uncomment option 2. Then you can change the **TFT\_** pins to whatever pins you'd like!

You can also save a pin by setting

`#define TFT_RST    9`

to

`#define TFT_RST   -1`

and connecting the RST line to the Arduino Reset pin. That way the Arduino will auto-reset the TFT as well.

# 1.8" TFT Display Breakout and Shield

## Displaying Bitmaps

![](https://cdn-learn.adafruit.com/assets/assets/000/001/911/medium800/lcds___displays_18tftlcdparrot_LRG.jpeg?1396777379)

In this example, we'll show how to display a 128x160 pixel full color bitmap from a microSD card.  
  
We have an example sketch in the library showing how to display full color bitmap images stored on an SD card. You'll need a [microSD card such as this one](http://www.adafruit.com/products/102).

It's really easy to draw bitmaps. We have a library for it, Adafruit\_ImageReader, which can be installed through the Arduino Library Manager&nbsp;(Sketch→Include Library→Manage Libraries…). Enter “imageread” in the search field and the library is easy to spot:

![](https://cdn-learn.adafruit.com/assets/assets/000/078/309/medium800/arduino_compatibles_ImageReader.png?1563387756)

You'll also need an image. We suggest starting with this bitmap of a parrot.

[Download parrot.bmp](http://learn.adafruit.com/system/assets/assets/000/010/143/original/parrot.bmp)
If you want to later use your own image, use an image editing tool and crop your image to no larger than 160 pixels high and 128 pixels wide. Save it as a 24-bit color **BMP** file - it must be 24-bit color format to work, even if it was originally a 16-bit color image - because of the way BMPs are stored and displayed!

Copy the **parrot.bmp** to the microSD card and insert it into the micro SD card holder on your shield or breakout board.

![](https://cdn-learn.adafruit.com/assets/assets/000/019/567/medium800/lcds___displays_358scale_ORIG.jpg?1409949008)

# Breakout Wiring

**Shield users** can skip directly to the " **Example Sketch**" section.  
  
Wire up the TFT as described on the wiring & test page and add the two wires for talking to the SD card. Connect&nbsp; **CARD\_CS** (the unconnected pin in the middle) to digital pin **4** (you can change this later to any pin you want). Connect **MISO** (second from the right) to the Arduino's hardware SPI **MISO** pin. For Classic arduinos, this is pin **12**. For Mega's this is pin **50**. You can't change the **MISO** pin, it's fixed in the chip hardware.

![](https://cdn-learn.adafruit.com/assets/assets/000/078/307/medium800/arduino_compatibles_ST7735-160x128.png?1563387002)

# Example Sketch
If you have the breakout, open the&nbsp; **File→examples→Adafruit ImageReader Library→**** BreakoutST7735 - 160x128&nbsp;**example.

![arduino_compatibles_example-160x128.png](https://cdn-learn.adafruit.com/assets/assets/000/078/315/medium640/arduino_compatibles_example-160x128.png?1563389273)

If you have the shield, open the&nbsp; **File→examples→Adafruit ImageReader Library→**** ShieldST7735&nbsp;**example.

![arduino_compatibles_example-7735Shield.png](https://cdn-learn.adafruit.com/assets/assets/000/078/316/medium640/arduino_compatibles_example-7735Shield.png?1563389311)

Now upload the&nbsp;example sketch to the Arduino. It should display the parrot image. If you have any problems, check the serial console for any messages such as not being able to initialize the microSD card or not finding the image.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/915/medium800/lcds___displays_parrot.jpeg?1396777410)

# 1.8" TFT Display Breakout and Shield

## CircuitPython Displayio Quickstart

You will need a board capable of running CircuitPython such as the Metro M0 Express or the Metro M4 Express. You can also use boards such as the Feather M0 Express or the Feather M4 Express. We recommend either the Metro M4 or the Feather M4 Express because it's much faster and works better for driving a display. For this guide, we will be using a Feather M4 Express. The steps should be about the same for the Feather M0 Express or either of the Metros. If you haven't already, be sure to check out our&nbsp;[Feather M4 Express](https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51/assembly)&nbsp;guide.

### Adafruit Feather M4 Express - Featuring ATSAMD51

[Adafruit Feather M4 Express - Featuring ATSAMD51](https://www.adafruit.com/product/3857)
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox, half bird, OK?) This feather is powered by our new favorite chip, the **ATSAMD51J19** -&nbsp; with...

In Stock
[Buy Now](https://www.adafruit.com/product/3857)
[Related Guides to the Product](https://learn.adafruit.com/products/3857/guides)
![Angled shot of a Adafruit Feather M4 Express. ](https://cdn-shop.adafruit.com/640x480/3857-10.jpg)

## Preparing the Breakout

Before using the TFT Breakout, you will need to solder the headers or some wires to it. Be sure to check out the&nbsp;[Adafruit Guide To Excellent Soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering).&nbsp;After that the breakout should be ready to go.

## Wiring the Breakout to the Feather

- **3-5V VCC** connects to the Feather&nbsp; **3V** pin
- **GND** connects toFeather ground
- **SCK** connects to SPI clock. On the Feather that's **SCK**.
- **MISO** connects to SPI MISO. On the Feather that's **MI**
- **MOSI** connects to SPI MOSI. On the Feather that's **MO**
- **TFT\_CS** connects to our SPI Chip Select pin. We'll be using **Digital 5** but you can later change this to any pin
- **D/C** connects to our SPI data/command select pin. We'll be using **Digital 6** but you can later change this pin too.
- **RESET** &nbsp;connects to our reset pin. We'll be using **Digital 9** but you can later change this pin too.
- **LITE** connects to the Feather **3V** pin. This is the only display that this pin is required to be connected or the backlight won't work.

![](https://cdn-learn.adafruit.com/assets/assets/000/116/511/medium800/arduino_compatibles_tft_fritzing_circuit.png?1667858706)

[Download Fritzing Object](https://cdn-learn.adafruit.com/assets/assets/000/116/512/original/160x128-breakout-feather-m4-fritzing.zip?1667860723)
## Required CircuitPython Libraries

To use this display with `displayio`, there is only one required library.

[Adafruit_CircuitPython_ST7735R](https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/releases)
First, make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next, you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle).&nbsp; Our introduction guide has&nbsp;[a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries)&nbsp;for both express and non-express boards.

Remember for non-express boards, you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_st7735r**

Before continuing make sure your board's lib folder or root filesystem has the&nbsp; **adafruit\_st7735r** &nbsp;file copied over.

## Code Example Additional Libraries

For the Code Example, you will need an additional library. We decided to make use of a library so the code didn't get overly complicated.

[Adafruit_CircuitPython_Display_Text](https://github.com/adafruit/Adafruit_CircuitPython_Display_Text)
Go ahead and install this in the same manner as the driver library by copying the&nbsp; **adafruit\_display\_text** folder over to the **lib** folder on your CircuitPython device.

## CircuitPython Code Example
https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/blob/main/examples/st7735r_128x160_simpletest.py

Let's take a look at the sections of code one by one.&nbsp;We start by importing the board so that we can initialize&nbsp;`SPI`,&nbsp;`displayio`,`terminalio` for the font, a `label`, and the&nbsp;`adafruit_st7735r`&nbsp;driver.

```
import board
import displayio
import terminalio
from adafruit_display_text import label
from adafruit_st7735r import ST7735R<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

Next we release any previously used displays. This is important because if the Feather is reset, the display pins are not automatically released and this makes them available for use again.

```
displayio.release_displays()<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

Next, we set the SPI object to the board's SPI with the easy shortcut function&nbsp;`board.SPI()`. By using this function, it finds the SPI module and initializes using the default SPI parameters.

```
spi = board.SPI()
tft_cs = board.D5
tft_dc = board.D6<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

In the next line, we set the display bus to FourWire which makes use of the SPI bus.

```
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

Finally, we initialize the driver with a width of 160 and a height of 128. If we stopped at this point and ran the code, we would have a terminal that we could type at and have the screen update. Because we want to use the display horizontally and the default orientation is vertical, we rotate it 90 degrees. One other parameter that we provide is `bgr=True`&nbsp;and the reason for this is that the color ordering of certain displays is Blue, Green, Red rather than the usual Red, Green, Blue. It tell displayio the correct color ordering for this particular display.

```
display = ST7735R(display_bus, width=160, height=128, rotation=90, bgr=True)
<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/478/medium800/arduino_compatibles_128x160-text.jpeg?1565887821)

Next we create a background splash image. We do this by creating a group that we can add elements to and adding that group to the display. In this example, we are limiting the maximum number of elements to 10, but this can be increased if you would like. The display will automatically handle updating the group.

```auto
splash = displayio.Group(max_size=10)
display.root_group = splash
```

Next we create a Bitmap which is like a canvas that we can draw on. In this case we are creating the Bitmap to be the same size as the screen, but only have one color. The Bitmaps can currently handle up to 256 different colors. We create a Palette with one color and set that color to 0x00FF00 which happens to be green. Colors are Hexadecimal values in the format of RRGGBB. Even though the Bitmaps can only handle 256 colors at a time, you get to define what those 256 different colors are.

```
color_bitmap = displayio.Bitmap(160, 128, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00 # Bright Green<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

With all those pieces in place, we create a TileGrid by passing the bitmap and palette and draw it at&nbsp;`(0, 0)`&nbsp;which represents the display's upper left.

```
bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0, y=0)
splash.append(bg_sprite)<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/479/medium800/arduino_compatibles_128x160-green.jpeg?1565887834)

Next we will create a smaller purple square. The easiest way to do this is the create a new bitmap that is a little smaller than the full screen with a single color and place it in a specific location. In this case, we will create a bitmap that is 5 pixels smaller on each side. The screen is **160x128** , so we'll want to subtract 10 from each of those numbers.

We'll also want to place it at the position&nbsp;`(5, 5)` so that it ends up centered.

```
inner_bitmap = displayio.Bitmap(150, 118, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088 # Purple
inner_sprite = displayio.TileGrid(inner_bitmap,
                                  pixel_shader=inner_palette,
                                  x=5, y=5)
splash.append(inner_sprite)<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

Since we are adding this after the first square, it's automatically drawn on top. Here's what it looks like now.

![](https://cdn-learn.adafruit.com/assets/assets/000/079/481/medium800/arduino_compatibles_128x160-green-purple.jpeg?1565887856)

Next let's add a label that says "Hello World!" on top of that. We're going to use the built-in Terminal Font and scale it up by a factor of two. To scale the label only, we will make use of a subgroup, which we will then add to the main group.

Labels are centered vertically, so we'll place it at 64 for the Y coordinate, and around 11 pixels make it appear to be centered horizontally, but if you want to change the text, change this to whatever looks good to you. Let's go with some yellow text, so we'll pass it a value of `0xFFFF00`.

```
text_group = displayio.Group(max_size=10, scale=2, x=11, y=64)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

Finally, we place an infinite loop at the end so that the graphics screen remains in place and isn't replaced by a terminal.

```
while True:
    pass<div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div>
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/482/medium800/arduino_compatibles_128x160-hello-world.jpeg?1565887866)

## Where to go from here

Be sure to check out this excellent&nbsp;[guide to CircuitPython Display Support Using displayio](https://learn.adafruit.com/circuitpython-display-support-using-displayio)

# 1.8" TFT Display Breakout and Shield

## Python Wiring and Setup

# Wiring
It's easy to use display breakouts with Python and the&nbsp;[Adafruit CircuitPython RGB Display](https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display)&nbsp;module.&nbsp; This module allows you to easily write Python code to control the display.

We'll cover how to wire the display to your Raspberry Pi. First assemble your display.

Since there's&nbsp;_dozens_&nbsp;of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Connect the display as shown below to your Raspberry Pi.

Info: 

Warning: 

## ILI9341 and HX-8357-based Displays

### 2.2" Display

- **CLK** connects to SPI clock. On the Raspberry Pi, that's **SCLK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, that's also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later.
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later as well.
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**

![](https://cdn-learn.adafruit.com/assets/assets/000/084/668/medium800/arduino_compatibles_2.2_TFT_bb.jpg?1574277297)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/669/original/2.2_TFT.fzz?1574277335)
### 2.4", 2.8", 3.2", and 3.5" Displays

These displays are set up to use the 8-bit data lines by default. We want to use them for SPI. To do that, you'll need to either solder bridge some pads on the back or connect the appropriate IM lines to 3.3V with jumper wires. Check the back of your display for the correct solder pads or IM lines to put it in SPI mode.

- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later.
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later as well.

Warning: 

![](https://cdn-learn.adafruit.com/assets/assets/000/084/676/medium800/arduino_compatibles_2.8_TFT_bb.jpg?1574277504)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/670/original/2.8_TFT.fzz?1574277361)
## ST7789 and ST7735-based Displays

### 1.3", 1.54", and 2.0" IPS TFT Display

- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/677/medium800/arduino_compatibles_2.0_TFT_bb.jpg?1574277527)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/671/original/2.0_TFT.fzz?1574277392)
### 0.96", 1.14", and 1.44" Displays

- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/678/medium800/arduino_compatibles_1.44_TFT_bb.jpg?1574277538)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/672/original/1.44_TFT.fzz?1574277409)
### 1.8" Display

- **GND** connects to the Raspberry Pi's **ground**
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **LITE** connects to the Raspberry Pi's **3V** pin. This can be used to separately control the backlight.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/679/medium800/arduino_compatibles_1.8_TFT_bb.jpg?1574277564)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/673/original/1.8_TFT.fzz?1574277427)
## SSD1351-based Displays

### 1.27" and 1.5" OLED Displays

- **GND** connects to the Raspberry Pi's **ground**
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later.
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later as well.

![](https://cdn-learn.adafruit.com/assets/assets/000/084/680/medium800/arduino_compatibles_1.5_OLED_bb.jpg?1574277589)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/084/674/original/1.5_OLED.fzz?1574277454)
## SSD1331-based Display

### 0.96" OLED Display

- **MOSI** connects to SPI MOSI. On the Raspberry Pi, thats also **MOSI**
- **CLK** connects to SPI clock. On the Raspberry Pi, thats **SLCK**
- **D/C** connects to our SPI Chip Select pin. We'll be using **GPIO 25** , but this can be changed later.
- **RST** &nbsp;connects to our Reset pin. We'll be using&nbsp; **GPIO 24** but this can be changed later as well.
- **CS** &nbsp;connects to our SPI Chip Select pin. We'll be using&nbsp; **CE0**
- **Vin** connects to the Raspberry Pi's **3V** &nbsp;pin
- **GND** connects to the Raspberry Pi's **ground**

![](https://cdn-learn.adafruit.com/assets/assets/000/096/091/medium800/arduino_compatibles_0.96_OLED_bb.jpg?1603118613)

[Download the Fritzing Diagram](https://cdn-learn.adafruit.com/assets/assets/000/096/092/original/0.96_OLED.fzz?1603118637)
# Setup

You'll need to install the Adafruit\_Blinka library that provides the CircuitPython support in Python. This may also require enabling SPI on your platform and verifying you are running Python 3. [Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Warning: 

## Python Installation of RGB Display Library

Once that's done, from your command line run the following command:

- `pip3 install adafruit-circuitpython-rgb-display`

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

If that complains about pip3 not being installed, then run this first to install it:

- `sudo apt-get install python3-pip`

## DejaVu TTF Font

Raspberry Pi usually comes with the DejaVu font already installed, but in case it didn't, you can run the following to install it:

- `sudo apt-get install fonts-dejavu`

This package was previously calls **ttf-dejavu** , so if you are running an older version of Raspberry Pi OS, it may be called that.

## Pillow Library

We also need PIL, the Python Imaging Library, to allow graphics and using text with custom fonts. There are several system libraries that PIL relies on, so installing via a package manager is the easiest way to bring in everything:

- `sudo apt-get install python3-pil`

If you installed the PIL through PIP, you may need to install some additional libraries:

- `sudo apt-get install libopenjp2-7 libtiff5 libatlas-base-dev`

That's it. You should be ready to go.

# 1.8" TFT Display Breakout and Shield

## Python Usage

Warning: 

Now that you have everything setup, we're going to look over three different examples. For the first, we'll take a look at automatically scaling and cropping an image and then centering it on the display.

## Turning on the Backlight

On some displays, the backlight is controlled by a separate pin such as the 1.3" TFT Bonnet with Joystick. On such displays, running the below code will likely result in the display remaining black. To turn on the backlight, you will need to add a small snippet of code. If your backlight pin number differs, be sure to change it in the code:

```python
# Turn on the Backlight
backlight = DigitalInOut(board.D26)
backlight.switch_to_output()
backlight.value = True
```

## Displaying an Image

Here's the full code to the example. We will go through it section by section to help you better understand what is going on. Let's start by downloading an image of Blinka. This image has enough border to allow resizing and cropping with a variety of display sizes and rations to still look good.

![](https://cdn-learn.adafruit.com/assets/assets/000/082/210/medium800/arduino_compatibles_blinka.jpg?1570817179)

Make sure you save it as **blinka.jpg** and place it in the same folder as your script. Here's the code we'll be loading onto the Raspberry Pi. We'll go over the interesting parts.

https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/main/examples/rgb_display_pillow_image.py

So we start with our usual imports including a couple of Pillow modules and the display drivers. That is followed by defining a few pins here. The reason we chose these is because they allow you to use the same code with the PiTFT if you chose to do so.

```python
import digitalio
import board
from PIL import Image, ImageDraw
import adafruit_rgb_display.ili9341 as ili9341
import adafruit_rgb_display.st7789 as st7789
import adafruit_rgb_display.hx8357 as hx8357
import adafruit_rgb_display.st7735 as st7735
import adafruit_rgb_display.ssd1351 as ssd1351
import adafruit_rgb_display.ssd1331 as ssd1331

# Configuration for CS and DC pins
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)
reset_pin = digitalio.DigitalInOut(board.D24)
```

Next we'll set the baud rate from the default 24 MHz so that it works on a variety of displays. The exception to this is the SSD1351 driver, which will automatically limit it to 16MHz even if you pass 24MHz. We'll set up out SPI bus and then initialize the display.

We wanted to make these examples work on as many displays as possible with very few changes. The ILI9341 display is selected by default. For other displays, go ahead and comment out these lines:

```python
disp = ili9341.ILI9341(
    spi,
    rotation=90,  # 2.2", 2.4", 2.8", 3.2" ILI9341
```

and uncomment the line appropriate for your display and possibly the line below in the case of longer initialization sequences. The displays have a rotation property so that it can be set in just one place.

```python
#disp = st7789.ST7789(spi, rotation=90,                            # 2.0" ST7789
#disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180,  # 1.3", 1.54" ST7789
#disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789
#disp = hx8357.HX8357(spi, rotation=180,                           # 3.5" HX8357
#disp = st7735.ST7735R(spi, rotation=90,                           # 1.8" ST7735R
#disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3,   # 1.44" ST7735R
#disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80,       # 0.96" MiniTFT Rev A ST7735R
#disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80,    # 0.96" MiniTFT Rev B ST7735R
#x_offset=26, y_offset=1,#disp = ssd1351.SSD1351(spi, rotation=180,                         # 1.5" SSD1351
#disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351
#disp = ssd1331.SSD1331(spi, rotation=180,                         # 0.96" SSD1331
disp = ili9341.ILI9341(
    spi,
    rotation=90,  # 2.2", 2.4", 2.8", 3.2" ILI9341
    cs=cs_pin,
    dc=dc_pin,
    rst=reset_pin,
    baudrate=BAUDRATE
)
```

Next we read the current rotation setting of the display and if it is 90 or 270 degrees, we need to swap the width and height for our calculations, otherwise we just grab the width and height. We will create an `image` with our dimensions and use that to create a `draw` object. The `draw` object will have all of our drawing functions.

```python
# Create blank image for drawing.
# Make sure to create image with mode 'RGB' for full color.
if disp.rotation % 180 == 90:
    height = disp.width   # we swap height/width to rotate it to landscape!
    width = disp.height
else:
    width = disp.width   # we swap height/width to rotate it to landscape!
    height = disp.height
image = Image.new('RGB', (width, height))
 
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
```

Next we clear whatever is on the screen by drawing a black rectangle. This isn't strictly necessary since it will be overwritten by the image, but it kind of sets the stage.

```python
# Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0))
disp.image(image)
```

Next we open the Blinka image, which we've named **blinka.jpg** , which assumes it is in the same directory that you are running the script from. Feel free to change it if it doesn't match your configuration.

```python
image = Image.open("blinka.jpg")
```

Here's where it starts to get interesting. We want to scale the image so that it matches either the width or height of the display, depending on which is smaller, so that we have some of the image to chop off when we crop it. So we start by calculating the width to height ration of both the display and the image. If the height is the closer of the dimensions, we want to match the image height to the display height and let it be a bit wider than the display. Otherwise, we want to do the opposite.

Once we've figured out how we're going to scale it, we pass in the new dimensions and using a **Bicubic** rescaling method, we reassign the newly rescaled image back to `image`. Pillow has quite a few different methods to choose from, but Bicubic does a great job and is reasonably fast.

```python
# Scale the image to the smaller screen dimension
image_ratio = image.width / image.height
screen_ratio = width / height
if screen_ratio &lt; image_ratio:
    scaled_width = image.width * height // image.height
    scaled_height = height
else:
    scaled_width = width
    scaled_height = image.height * width // image.width
image = image.resize((scaled_width, scaled_height), Image.BICUBIC)
```

Next we want to figure the starting x and y points of the image where we want to begin cropping it so that it ends up centered. We do that by using a standard centering function, which is basically requesting the difference of the center of the display and the center of the image. Just like with scaling, we replace the `image` variable with the newly cropped image.

```python
# Crop and center the image
x = scaled_width // 2 - width // 2
y = scaled_height // 2 - height // 2
image = image.crop((x, y, x + width, y + height))
```

Finally, we take our image and display it. At this point, the image should have the exact same dimensions at the display and fill it completely.

```python
disp.image(image)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/228/medium800/arduino_compatibles_2.2_Breakout_Image.jpeg?1570818097)

## Drawing Shapes and Text

In the next example, we'll take a look at drawing shapes and text. This is very similar to the displayio example, but it uses Pillow instead. Here's the code for that.

https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/main/examples/rgb_display_pillow_demo.py

Just like in the last example, we'll do our imports, but this time we're including the `ImageFont` Pillow module because we'll be drawing some text this time.

```python
import digitalio
import board
from PIL import Image, ImageDraw, ImageFont
import adafruit_rgb_display.ili9341 as ili9341
```

Next we'll define some parameters that we can tweak for various displays. The `BORDER` will be the size in pixels of the green border between the edge of the display and the inner purple rectangle. The `FONTSIZE` will be the size of the font in points so that we can adjust it easily for different displays.

```python
BORDER = 20
FONTSIZE = 24
```

Next, just like in the previous example, we will set up the display, setup the rotation, and create a draw object. **If you have are using a different display than the ILI9341, go ahead and adjust your initializer as explained in the previous example.** After that, we will setup the background with a green rectangle that takes up the full screen. To get green, we pass in a tuple that has our **Red** , **Green** , and **Blue** color values in it in that order which can be any integer from `0` to `255`.

```python
draw.rectangle((0, 0, width, height), fill=(0, 255, 0))
disp.image(image)
```

Next we will draw an inner purple rectangle. This is the same color value as our example in displayio quickstart, except the hexadecimal values have been converted to decimal. We use the `BORDER` parameter to calculate the size and position that we want to draw the rectangle.

```python
draw.rectangle((BORDER, BORDER, width - BORDER - 1, height - BORDER - 1),
               fill=(170, 0, 136))
```

Next we'll load a TTF font. The `DejaVuSans.ttf` font should come preloaded on your Pi in the location in the code. We also make use of the `FONTSIZE` parameter that we discussed earlier.

```python
# Load a TTF Font
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', FONTSIZE)
```

Now we draw the text Hello World onto the center of the display. You may recognize the centering calculation was the same one we used to center crop the image in the previous example. In this example though, we get the font size values using the `getsize()` function of the font object.

```python
# Draw Some Text
text = "Hello World!"
(font_width, font_height) = font.getsize(text)
draw.text((width//2 - font_width//2, height//2 - font_height//2),
          text, font=font, fill=(255, 255, 0))
```

Finally, just like before, we display the image.

```python
disp.image(image)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/164/medium800/arduino_compatibles_2.2_Breakout_Demo.jpeg?1570647999)

## Displaying System Information

In this last example we'll take a look at getting the system information and displaying it. This can be very handy for system monitoring. Here's the code for that example:

https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/blob/main/examples/rgb_display_pillow_stats.py

Just like the last example, we'll start by importing everything we imported, but we're adding two more imports. The first one is `time` so that we can add a small delay and the other is `subprocess` so we can gather some system information.

```python
import time
import subprocess
import digitalio
import board
from PIL import Image, ImageDraw, ImageFont
import adafruit_rgb_display.ili9341 as ili9341
```

Next, just like in the first two examples, we will set up the display, setup the rotation, and create a draw object. **If you have are using a different display than the ILI9341, go ahead and adjust your initializer as explained in the previous example.**

Just like in the first example, we're going to draw a black rectangle to fill up the screen. After that, we're going to set up a couple of constants to help with positioning text. The first is the `padding` and that will be the Y-position of the top-most text and the other is `x` which is the X-Position and&nbsp;represents the left side of the text.

```python
# First define some constants to allow easy positioning of text.
padding = -2
x = 0
```

Next, we load a font just like in the second example.

```python
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24)
```

Now we get to the main loop and by using `while True:`, it will loop until **Control+C** is pressed on the keyboard. The first item inside here, we clear the screen, but notice that instead of giving it a tuple like before, we can just pass `0` and it will draw black.

```python
draw.rectangle((0, 0, width, height), outline=0, fill=0)
```

Next, we run a few scripts using the `subprocess` function that get called to the Operating System to get information. The in each command is passed through awk in order to be formatted better for the display. By having the OS do the work, we don't have to. These little scripts came from `https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load`

```python
cmd = "hostname -I | cut -d\' \' -f1"
IP = "IP: "+subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
CPU = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB  %.2f%%\", $3,$2,$3*100/$2 }'"
MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%d GB  %s\", $3,$2,$5}'"
Disk = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "cat /sys/class/thermal/thermal_zone0/temp |  awk \'{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}\'" # pylint: disable=line-too-long
Temp = subprocess.check_output(cmd, shell=True).decode("utf-8")
```

Now we display the information for the user. Here we use yet another way to pass color information. We can pass it as a color string using the pound symbol, just like we would with HTML. With each line, we take the height of the line using `getsize()` and move the pointer down by that much.

```python
y = padding
draw.text((x, y), IP, font=font, fill="#FFFFFF")
y += font.getsize(IP)[1]
draw.text((x, y), CPU, font=font, fill="#FFFF00")
y += font.getsize(CPU)[1]
draw.text((x, y), MemUsage, font=font, fill="#00FF00")
y += font.getsize(MemUsage)[1]
draw.text((x, y), Disk, font=font, fill="#0000FF")
y += font.getsize(Disk)[1]
draw.text((x, y), Temp, font=font, fill="#FF00FF")
```

Finally, we write all the information out to the display using `disp.image()`. Since we are looping, we tell Python to sleep for `0.1` seconds so that the CPU never gets too busy.

```python
disp.image(image)
time.sleep(.1)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/082/169/medium800/arduino_compatibles_2.2_Breakout_Stats.jpeg?1570657644)

# 1.8" TFT Display Breakout and Shield

## 1.8" TFT Shield V2

Let's take a tour of the 1.8" TFT Shield

![](https://cdn-learn.adafruit.com/assets/assets/000/065/534/medium800/arduino_compatibles_pinouts.jpg?1541981318)

# TFT Display
In the center is the 1.8" TFT display. This display is full color (16-bit RGB), 128x160 pixels, and has a backlight. The display receives data over SPI plus two pins:

- SCK - SPI Clock
- MOSI - SPI Data
- Digital 10 - Chip Select
- Digital 8 - Data/Command Select

The TFT reset is connected to the seesaw chip. The backlight is also PWM controlled by the seesaw chip. The 4 SPI+control pins, however, must be controlled directly by the Arduino

![arduino_compatibles_tft.jpg](https://cdn-learn.adafruit.com/assets/assets/000/065/537/medium640/arduino_compatibles_tft.jpg?1541982620)

# Buttons & Joystick
In addition of the display, you also get a bunch of user-interface buttons.

In the top left is the **Reset** button, this will reset the shield and Arduino when pressed. It is connected directly to the Reset pins

There are three buttons labeled **A B C** below the TFT, these are connected to the seesaw chip. You can read the values over I2C

To the right of the TFT is a 5-way joystick. It can be pushed up/down/left/right and select (in). It is connected to the seesaw chip, you can read the joystick over I2C

![arduino_compatibles_buttons.jpg](https://cdn-learn.adafruit.com/assets/assets/000/065/539/medium640/arduino_compatibles_buttons.jpg?1541982710)

# SD Card
The micro SD card slot can be used to read/write data from any micro SD card using the Arduino libraries. The SD card is connected to the SPI pins as well as **Digital #4** for **Chip Select**

The SD card is not required for use, but it's handy for storing images

![arduino_compatibles_sd.jpg](https://cdn-learn.adafruit.com/assets/assets/000/065/540/medium640/arduino_compatibles_sd.jpg?1541982883)

# seesaw I2C Expander
Instead of taking up a bunch of GPIO pins to read the buttons and joystick, as well as controlling the TFT backlight, we use an I2C expander chip called the **seesaw**. It is connected to the SDA/SCL pins and can read/write pins with our library. This saves a ton of pins and then you can always use the I2C pins for other sensors, as long as the address doesnt conflict

&nbsp;

**Don't forget!** Since the seesaw chip is used for the TFT backlight and reset, **you need to activate it even if you are not reading the buttons or joystick.**

![arduino_compatibles_seesaw.jpg](https://cdn-learn.adafruit.com/assets/assets/000/065/542/medium640/arduino_compatibles_seesaw.jpg?1541983027)

# 1.8" TFT Display Breakout and Shield

## Testing the Shield

You can test your assembled shield using the example code from the library.

Start by installing a bunch of libraries!

## Open the Arduino Library manager
![](https://cdn-learn.adafruit.com/assets/assets/000/065/547/medium800/arduino_compatibles_libmanager.png?1541983232)

Install the **Adafruit GFX Library**

![](https://cdn-learn.adafruit.com/assets/assets/000/065/548/medium800/arduino_compatibles_image.png?1541983286)

If using an older version of the Arduino IDE (pre-1.8.10), also locate and install the **Adafruit\_BusIO** library (newer versions do this automatically when using the Arduino Library Manager).

 **Adafruit ST7735 Library**

![](https://cdn-learn.adafruit.com/assets/assets/000/065/549/medium800/arduino_compatibles_image.png?1541983304)

 **Adafruit seesaw Library**

![](https://cdn-learn.adafruit.com/assets/assets/000/065/555/medium800/arduino_compatibles_image.png?1541983379)

[You can read more about installing libraries in our tutorial](http://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-libraries).  
  
Restart the Arduino IDE.

# 1.8" Shield with seesaw
If your shield looks like this, you have the 1.8" seesaw version (the most recent) which will work with just about any/all boards. For this version load up the **seesaw\_shield18\_test example**

![arduino_compatibles_pinouts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/065/558/medium640/arduino_compatibles_pinouts.jpg?1541983638)

![](https://cdn-learn.adafruit.com/assets/assets/000/065/557/medium800/arduino_compatibles_image.png?1541983592)

Upload to your microcontroller, and open the serial port watcher at **9600** baud:

The sketch waits until the serial port is opened (you can make it auto-start once you know things are working by removing the `while (!Serial);` line

&nbsp;

Check that the seesaw chip is detected, you should see text display on the TFT after a quick draw test.

If you don't have an SD card inserted, it will fail to init the SD card, that's ok you can continue with the test

![arduino_compatibles_image.png](https://cdn-learn.adafruit.com/assets/assets/000/065/572/medium640/arduino_compatibles_image.png?1541984632)

Once you've gotten this far try pressing all the buttons on the board (except for RESET) to activate the invert-blinking loop.

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/065/645/medium800thumb/arduino_compatibles_ezgif-4-430b34d52a3b.jpg?1541985597)

[For more details about seesaw, check out our guide](https://learn.adafruit.com/adafruit-seesaw-atsamd09-breakout) - we made a nice wrapper for the 1.8" TFT to control the backlight and read buttons but it still might be useful to know the underlying protocol

## Displaying a Bitmap

If you have [parrot.bmp](http://learn.adafruit.com/system/assets/assets/000/010/143/original/parrot.bmp) stored on the SD card you will get a nice parrot display once the buttons have all been pressed

![](https://cdn-learn.adafruit.com/assets/assets/000/065/623/medium800/arduino_compatibles_image.png?1541985212)

# 1.8" TFT Display Breakout and Shield

## CircuitPython Displayio Quickstart

You will need a Metro capable of running CircuitPython such as the Metro M0 Express or the Metro M4 Express. We recommend the Metro M4 Express because it's much faster and works better for driving a display. The steps should be about the same for the Metro M0 Express. If you haven't already, be sure to check out our&nbsp;[Adafruit Metro M4 Express featuring ATSAMD51](https://learn.adafruit.com/adafruit-metro-m4-express-featuring-atsamd51)&nbsp;guide.

### Adafruit Metro M4 feat. Microchip ATSAMD51

[Adafruit Metro M4 feat. Microchip ATSAMD51](https://www.adafruit.com/product/3382)
Are you ready? Really ready? Cause here comes the fastest, most powerful Metro ever. The **Adafruit Metro M4** featuring the **Microchip ATSAMD51**. This Metro is like a bullet train, with its 120MHz Cortex M4 with floating point support. Your code will zig and zag...

In Stock
[Buy Now](https://www.adafruit.com/product/3382)
[Related Guides to the Product](https://learn.adafruit.com/products/3382/guides)
![Angled shot of a Adafruit Metro M4 feat. Microchip ATSAMD51. ](https://cdn-shop.adafruit.com/640x480/3382-13.jpg)

You could use a Grand Central which also has an M4 Processor. For this board, be sure to check out our&nbsp;[Introducing the Adafruit Grand Central M4 Express](https://learn.adafruit.com/adafruit-grand-central)&nbsp;guide.

### Adafruit Grand Central M4 Express featuring the SAMD51

[Adafruit Grand Central M4 Express featuring the SAMD51](https://www.adafruit.com/product/4064)
Are you ready? Really ready? Cause here comes the **Adafruit Grand Central** featuring the **Microchip ATSAMD51**. This dev board is so big, it's not named after a Metro train, it's a whole freakin' _station_!

This board is like a freight...

In Stock
[Buy Now](https://www.adafruit.com/product/4064)
[Related Guides to the Product](https://learn.adafruit.com/products/4064/guides)
![Angled Shot of the Adafruit Grand Central M4 Express featuring the SAMD51.](https://cdn-shop.adafruit.com/640x480/4064-05.jpg)

If you need WiFi capabilities for your project, you could also use the Metro M4 Airlift Lite. For this board, be sure to check out our [Adafruit Metro M4 Express AirLift](https://learn.adafruit.com/adafruit-metro-m4-express-airlift-wifi) guide.

### Adafruit Metro M4 Express AirLift (WiFi) - Lite

[Adafruit Metro M4 Express AirLift (WiFi) - Lite](https://www.adafruit.com/product/4000)
Give your next project a lift with _AirLift_ - our witty name for the ESP32 co-processor that graces this Metro M4. You already know about the&nbsp; **Adafruit Metro M4** &nbsp;featuring the&nbsp; **Microchip ATSAMD51** , with it's 120MHz Cortex M4 with...

In Stock
[Buy Now](https://www.adafruit.com/product/4000)
[Related Guides to the Product](https://learn.adafruit.com/products/4000/guides)
![Adafruit Metro M4 Airlift Lite dev board with SAMD51 an ESP32 Wifi Co-processor.](https://cdn-shop.adafruit.com/640x480/4000-08.jpg)

## Preparing the Shield

Before using the TFT Shield, you will need to solder the headers on. Be sure to check out the&nbsp;[Adafruit Guide To Excellent Soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering).&nbsp;After that the shield should be ready to go.

## Required CircuitPython Libraries

To use this display with `displayio`, there are a few required libraries. You will need the display driver and since this is no ordinary display and has some additional controls, you will also need the seesaw and busdevice libraries.

[Adafruit_CircuitPython_BusDevice](https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/releases)
[Adafruit_CircuitPython_seesaw/releases](https://github.com/adafruit/Adafruit_CircuitPython_seesaw/releases)
[Adafruit_CircuitPython_ST7735R](https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/releases)
First, make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next, you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle).&nbsp; Our introduction guide has&nbsp;[a great page on how to install the library bundle](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries)&nbsp;for both express and non-express boards.

Remember for non-express boards, you'll need to manually install the necessary libraries from the bundle:

- **adafruit\_st7735r**
- **adafruit\_seesaw**
- **adafruit\_bus\_device**

Before continuing make sure your board's lib folder or root filesystem has the&nbsp; **adafruit\_st7735r** ,&nbsp; **adafruit\_seesaw&nbsp;** and&nbsp; **adafruit\_bus\_device** &nbsp;files and&nbsp;folders **&nbsp;** copied over.

## CircuitPython Code Example
https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/blob/main/examples/st7735r_18tftshield_buttons.py

Let's take a look at the sections of code one by one.&nbsp;We start by importing `time`, so we can pause, the `board` so that we can initialize&nbsp;SPI,&nbsp;`displayio`, the `tftshield18` seesaw&nbsp;library, and the&nbsp;`adafruit_ili9341`&nbsp;driver.

```auto
import time
import board
import displayio
import fourwire
from adafruit_seesaw.tftshield18 import TFTShield18
from adafruit_st7735r import ST7735R
```

Next we release any previously used displays. This is important because if the Metro is reset, the display pins are not automatically released and this makes them available for use again.

```
displayio.release_displays()
```

We set up seesaw using the TFTShield18, which was written specifically for this shield to make things very easy.

```
ss = TFTShield18()
```

Next, we set the SPI object to the board's SPI with the easy shortcut function&nbsp;`board.SPI()`. By using this function, it finds the SPI module and initializes using the default SPI parameters. Next we set the Chip Select and Data/Command pins that will be used.

```
spi = board.SPI()
tft_cs = board.D10
tft_dc = board.D8
```

In the next line, we set the display bus to an instance of FourWire which makes use of the SPI bus.

```python
display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs)
```

Finally, we reset the display, initialize the driver with a width of 160 and a height of 128, and turn on the backlight. If we stopped at this point and ran the code, we would have a terminal that we could type at and have the screen update.

```
ss.tft_reset()
display = ST7735R(display_bus, width=160, height=128, rotation=90, bgr=True)

ss.set_backlight(True)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/079/116/medium800/arduino_compatibles_IMG_0584.jpeg?1565110527)

Finally, we place an infinite loop at the end and constantly read the buttons. If a button is detected as being pressed, a message specifies which one. Multiple buttons can be pressed at the same time. We also provide an optional small delay to allow you to adjust how quickly you want the buttons to read in case you want to debounce the output.

```
while True:
    buttons = ss.buttons

    if buttons.right:
        print("Button RIGHT!")

    if buttons.down:
        print("Button DOWN!")

    if buttons.left:
        print("Button LEFT!")

    if buttons.up:
        print("Button UP!")

    if buttons.select:
        print("Button SELECT!")

    if buttons.a:
        print("Button A!")

    if buttons.b:
        print("Button B!")

    if buttons.c:
        print("Button C!")

    time.sleep(.001)
```

Now go ahead and run the code. Once it's running, try pushing a few buttons and see what happens.

![](https://cdn-learn.adafruit.com/assets/assets/000/079/117/medium800/arduino_compatibles_IMG_0583.jpeg?1565110551)

## Where to go from here

Be sure to check out this excellent&nbsp;[guide to CircuitPython Display Support Using displayio](https://learn.adafruit.com/circuitpython-display-support-using-displayio)

# 1.8" TFT Display Breakout and Shield

## Original V1 Shield

# Original V1.0 Shield
If your shield looks like this, you have the original 1.8" TFT shield which does not have a helper seesaw chip

![arduino_compatibles_lcds___displays_2013_05_03_IMG_1762-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/416/medium640/arduino_compatibles_lcds___displays_2013_05_03_IMG_1762-1024.jpg?1541984351)

The shield uses the "Classic Arduino" SPI wiring and will perform best with Atmega 328-based Arduinos such as the Uno. It can work with other Arduinos but not very well.

Load up the **shieldtest** demo

![](https://cdn-learn.adafruit.com/assets/assets/000/065/559/medium800/arduino_compatibles_image.png?1541984486)

&nbsp;

If you are using an Arduino UNO, Duemilanove or compatible with the ATmega328 chipset, you don't have to do anything! If you're using a Mega, Leonardo, Due or other non-ATmega328 chipset, you'll have to make a modification  
  
To use with the shield, modify the example code pin definitions as follows.

Find these lines:

```
// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
```

Warning: 

The Example code has 2 options for defining the display object. **Uno, Duemilanove** and other Atmega 328-based processors can use the "Option 1" version of the constructor for best performance:

```
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);
```

 **Mega** and **Leonardo** users should use the "Option 2" version of the constructor for compatibility:

```
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
```

Be sure to select only one option and comment out the other with a pair of //'s.

Now upload the sketch to see the graphical display!

# 1.8" TFT Display Breakout and Shield

## Assembling the Shield

![](https://cdn-learn.adafruit.com/assets/assets/000/008/403/medium800/lcds___displays_2013_05_02_IMG_1738-1024.jpg?1396864765)

The shield comes with all surface mount parts pre-soldered. All that remains is to install the headers!

## Cut the Header Sections
Cut the breakaway header strip into sections to fit the holes on the edge of the shield. You will need 2 sections of 6-pins and 2 sections of 8 pins.  
  
You can use wire-cutters as shown or pliers to snap them apart between pins.![lcds___displays_2013_05_02_IMG_1741-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/404/medium640/lcds___displays_2013_05_02_IMG_1741-1024.jpg?1396864775)

![lcds___displays_2013_05_02_IMG_1743-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/405/medium640/lcds___displays_2013_05_02_IMG_1743-1024.jpg?1396864791)

## Insert the Headers into an Arduino
To align the header strips for soldering, insert them (long pins down) into the headers of an Arduino.   
  
**Note that for R3 and later Arduinos, there will be an extra 2 unused pins on the end closest the USB and DC power jacks.** ![lcds___displays_2013_05_02_IMG_1745-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/407/medium640/lcds___displays_2013_05_02_IMG_1745-1024.jpg?1396864801)

![lcds___displays_2013_05_02_IMG_1748-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/408/medium640/lcds___displays_2013_05_02_IMG_1748-1024.jpg?1396864812)

## Add the Shield
Place the shield over the header strips so that the short pins stick up through the holes.![lcds___displays_2013_05_02_IMG_1749-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/409/medium640/lcds___displays_2013_05_02_IMG_1749-1024.jpg?1396864820)

![lcds___displays_2013_05_02_IMG_1750-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/410/medium640/lcds___displays_2013_05_02_IMG_1750-1024.jpg?1396864835)

![lcds___displays_2013_05_02_IMG_1751-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/411/medium640/lcds___displays_2013_05_02_IMG_1751-1024.jpg?1396864850)

## And Solder!
Solder each pin to assure good electrical contact.   
  
For tips on soldering see the [Adafruit Guide to Excellent Soldering](http://learn.adafruit.com/adafruit-guide-excellent-soldering "Link: http://learn.adafruit.com/adafruit-guide-excellent-soldering").![lcds___displays_2013_05_02_IMG_1753-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/412/medium640/lcds___displays_2013_05_02_IMG_1753-1024.jpg?1396864861)

![lcds___displays_2013_05_02_IMG_1758-1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/008/413/medium640/lcds___displays_2013_05_02_IMG_1758-1024.jpg?1396864873)

# 1.8" TFT Display Breakout and Shield

## Reading the Joystick

![](https://cdn-learn.adafruit.com/assets/assets/000/008/419/medium800/lcds___displays_2013_05_03_IMG_1763.jpg?1396864970)

The 5-way joystick on the shield is great for implementing menu navigation or even for use as a tiny game controller. To minimize the number of pins required, the joystick uses a different resistor on each leg of the control to create a variable voltage divider that can be monitored with a single analog pin. Each movement of the joystick control connects a different resistor and results in a different voltage reading.

![](https://cdn-learn.adafruit.com/assets/assets/000/008/420/medium800/lcds___displays_Capture.jpg?1396864981)

In the code example below, the CheckJoystick() function reads the analog pin and compares the result with 5 different ranges to determine which (if any) direction the stick has been moved. If you upload this to your Arduino and open the Serial Monitor, you will see the current joystick state printed to the screen.  
  
You can use this code as the input method for your menu system or game:

```
void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

#define Neutral 0
#define Press 1
#define Up 2
#define Down 3
#define Right 4
#define Left 5

// Check the joystick position
int CheckJoystick()
{
  int joystickState = analogRead(3);
  
  if (joystickState &lt; 50) return Left;
  if (joystickState &lt; 150) return Down;
  if (joystickState &lt; 250) return Press;
  if (joystickState &lt; 500) return Right;
  if (joystickState &lt; 650) return Up;
  return Neutral;
}

void loop() 
{
  int joy = CheckJoystick();
  switch (joy)
  {
    case Left:
      Serial.println("Left");
      break;
    case Right:
      Serial.println("Right");
      break;
    case Up:
      Serial.println("Up");
      break;
    case Down:
      Serial.println("Down");
      break;
    case Press:
      Serial.println("Press");
      break;
  }
}
```

# 1.8" TFT Display Breakout and Shield

## Graphics Library

We've written a full graphics library specifically for this display which will get you up and running quickly. The code is written in C/C++ for Arduino but is easy to port to any microcontroller by rewritting the low level pin access functions.  
  
The TFT LCD library is based off of the Adafruit GFX graphics core library. GFX has many ready to go functions that should help you start out with your project. It's not exhaustive and we'll try to update it if we find a really useful function. Right now it supports pixels, lines, rectangles, circles, round-rects, triangles and printing text as well as rotation.  
  
<u>Two</u> libraries need to be downloaded and installed: first is the [ST7735 library](https://github.com/adafruit/Adafruit-ST7735-Library) (this contains the low-level code specific to this device), and second is the [Adafruit GFX Library](https://github.com/adafruit/Adafruit-GFX-Library "Link: https://github.com/adafruit/Adafruit-GFX-Library") (which handles graphics operations common to many displays we carry). You can install these with the Arduino library manager.

Open up the Arduino library manager:

![](https://cdn-learn.adafruit.com/assets/assets/000/084/227/medium800/arduino_compatibles_library_manager_menu.png?1573776770)

Search for the&nbsp; **Adafruit ST7735&nbsp;** library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/084/228/medium800/arduino_compatibles_st7735.png?1573776914)

Search for the&nbsp; **Adafruit GFX** library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/084/229/medium800/arduino_compatibles_gfx.png?1573776951)

![](https://cdn-learn.adafruit.com/assets/assets/000/001/910/medium800/lcds___displays_st7735squares.jpeg?1396777369)

[Check out the GFX tutorial for detailed information about what is supported and how to use it](http://learn.adafruit.com/adafruit-gfx-graphics-library "Link: http://learn.adafruit.com/adafruit-gfx-graphics-library")! # 1.8" TFT Display Breakout and Shield

## Troubleshooting

### 

The display driver circuit needs a small amount of time to be ready after initial power. If your code tries to write to the display too soon, it may not be ready. It will work on reset since that typically does not cycle power. If you are having this issue, try adding a small amount of delay before trying to write to the display.

In Arduino, use **delay()** to add a few milliseconds before calling **tft.begin()**. Adjust the amount of delay as needed to see how little you can get away with for your specific setup.

# 1.8" TFT Display Breakout and Shield

## Downloads

# Files & Datasheets

- [Adafruit GFX library](https://github.com/adafruit/Adafruit-GFX-Library)
- [Adafruit ST7735 library](https://github.com/adafruit/Adafruit-ST7735-Library)([See our detailed tutorial for installation assistance](http://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-libraries))
- [Fritzing object in the Adafruit library](https://github.com/adafruit/Fritzing-Library)
- [Fritzing object for v2 of the 1.8" Shield](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%201.8%20Color%20TFT%20Shield%20with%20microSD%20and%20Joystick%20-%20v2.fzpz)
- [Datasheet for the display](http://www.adafruit.com/datasheets/JD-T1800.pdf)
- [Datasheet for the display driver chip](http://www.adafruit.com/datasheets/ST7735R_V0.2.pdf).
- [EagleCAD PCB files for TFT shield](https://github.com/adafruit/Adafruit-1.8-TFT-Shield)
- [EagleCAD PCB files for TFT breakout](https://github.com/adafruit/1.8-TFT-breakout)

# Breakout Schematic
![](https://cdn-learn.adafruit.com/assets/assets/000/035/826/medium800/lcds___displays_schem.png?1474423185)

For the level shifter we use the CD74HC4050 which has a typical propagation delay of ~10ns

# Breakout Fabrication print
![](https://cdn-learn.adafruit.com/assets/assets/000/035/827/medium800/lcds___displays_fabprint.png?1474423209)

# Shield v2 Schematic & Fab Print

This is the newer seesaw version

![](https://cdn-learn.adafruit.com/assets/assets/000/065/532/medium800/arduino_compatibles_schem.png?1541980272)

![](https://cdn-learn.adafruit.com/assets/assets/000/065/533/medium800/arduino_compatibles_fabprint.png?1541980278)

# Shield V1 Schematic & Fab Print

This is the 'original' non-seesaw version

![](https://cdn-learn.adafruit.com/assets/assets/000/035/824/medium800/lcds___displays_schem.png?1474422858)

![](https://cdn-learn.adafruit.com/assets/assets/000/035/825/medium800/lcds___displays_fabprint.png?1474422891)


## Featured Products

### Breadboarding wire bundle

[Breadboarding wire bundle](https://www.adafruit.com/product/153)
75 flexible stranded core wires with stiff ends molded on in red, orange, yellow, green, blue, brown, black and white. These are a major improvement over the "box of bent wires" that are sometimes sold with breadboards, and faster than stripping your own solid core wires. Makes...

In Stock
[Buy Now](https://www.adafruit.com/product/153)
[Related Guides to the Product](https://learn.adafruit.com/products/153/guides)
### Adafruit METRO 328 Fully Assembled - Arduino IDE compatible

[Adafruit METRO 328 Fully Assembled - Arduino IDE compatible](https://www.adafruit.com/product/50)
We sure love the ATmega328 here at Adafruit, and we use them&nbsp;_a lot_&nbsp;for our own projects. The processor has plenty of GPIO, Analog inputs, hardware UART SPI and I2C, timers and PWM galore - just enough for most simple projects. When we need to go small, we use a <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/50)
[Related Guides to the Product](https://learn.adafruit.com/products/50/guides)
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

Out of Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
### 1.8" Color TFT LCD display with MicroSD Card Breakout

[1.8" Color TFT LCD display with MicroSD Card Breakout](https://www.adafruit.com/product/358)
This lovely little display breakout is the best way to add a small, colorful and bright display to any project. Since the display uses 4-wire SPI to communicate and has its own pixel-addressable frame buffer, it can be used with every kind of microcontroller. Even a very small one with low...

Out of Stock
[Buy Now](https://www.adafruit.com/product/358)
[Related Guides to the Product](https://learn.adafruit.com/products/358/guides)
### Adafruit 1.8" Color TFT Shield w/microSD and Joystick

[Adafruit 1.8" Color TFT Shield w/microSD and Joystick](https://www.adafruit.com/product/802)
This lovely little shield is the best way to add a small, colorful and bright display to any project. We took our popular 1.8" TFT breakout board and remixed it into an Arduino shield complete with microSD card slot and a 5-way joystick navigation switch and three selection buttons! Since...

In Stock
[Buy Now](https://www.adafruit.com/product/802)
[Related Guides to the Product](https://learn.adafruit.com/products/802/guides)
### 1.8" SPI TFT display, 160x128 18-bit color - ST7735R driver

[1.8" SPI TFT display, 160x128 18-bit color - ST7735R driver](https://www.adafruit.com/product/618)
We just love this little 1.8" TFT display, with true TFT color (up to 18-bits per pixel!), fine 160x128 resolution, two white LED backlight that runs on 3.3V and a very easy SPI interface that requires only 4 or 5 digital pins to send pixels to the display.  
  
**Please...**

Out of Stock
[Buy Now](https://www.adafruit.com/product/618)
[Related Guides to the Product](https://learn.adafruit.com/products/618/guides)

## Related Guides

- [Bluetooth Temperature & Humidity Sensor](https://learn.adafruit.com/bluetooth-temperature-and-humidity-sensor.md)
- [Analog Feedback Servos](https://learn.adafruit.com/analog-feedback-servos.md)
- [WiFi Controlled LED Christmahanukwanzaa Tree](https://learn.adafruit.com/wifi-controlled-led-christmahanukwanzaa-tree.md)
- [Adafruit 1.27" and 1.5" Color OLED Breakout Board](https://learn.adafruit.com/adafruit-1-5-color-oled-breakout-board.md)
- [Smart Cocktail Shaker](https://learn.adafruit.com/smart-cocktail-shaker.md)
- [WiFi Controlled Mobile Robot](https://learn.adafruit.com/wifi-controlled-mobile-robot.md)
- [2.8" TFT Touch Shield](https://learn.adafruit.com/2-8-tft-touch-shield.md)
- [Arduino GPS Clock](https://learn.adafruit.com/arduino-clock.md)
- [WiFi Candy Bowl Monitor](https://learn.adafruit.com/wifi-candy-bowl.md)
- [Adafruit Proto Shield for Arduino](https://learn.adafruit.com/adafruit-proto-shield-arduino.md)
- [DIY 8x2 LCD Shield](https://learn.adafruit.com/diy-8x2-lcd-shield.md)
- [How to program a Zumo Robot with Simulink](https://learn.adafruit.com/zumo-robot-control-with-simulink.md)
- [IR Sensor](https://learn.adafruit.com/ir-sensor.md)
- [Arduino Lesson 5. The Serial Monitor](https://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitor.md)
- [TTL Serial Camera](https://learn.adafruit.com/ttl-serial-camera.md)
