1.8 Inch TFT LCD Module Documentation
The 1.8 inch TFT LCD Module is a compact, color display module designed for IoT and robotics applications. It features a 1.8-inch active matrix TFT-LCD display with a resolution of 160x128 pixels. The module is equipped with a built-in ST7735S driver and provides a SPI interface for communication.
Display Size: 1.8 inches
Resolution: 160x128 pixels
Display Type: Active Matrix TFT-LCD
Driver IC: ST7735S
Interface: SPI
Power Supply: 3.3V - 5V
Operating Temperature: -20C to 70C
The module has a 16-pin interface, with the following pinout:
| Pin | Function |
| --- | --- |
| 1 | VCC (3.3V - 5V) |
| 2 | GND |
| 3 | SCL (SPI Clock) |
| 4 | SDA (SPI Data) |
| 5 | RST (Reset) |
| 6 | CS (Chip Select) |
| 7-10 | D0-D3 (SPI Data) |
| 11-14 | D4-D7 (SPI Data) |
| 15 | LED+ (Backlight Positive) |
| 16 | LED- (Backlight Negative) |
### Example 1: Basic Display Initialization and Text Display (Arduino)
This example demonstrates how to initialize the display and display a simple text message.
```c
#include <SPI.h>
#include <ST7735.h>
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
ST7735 tft = ST7735(TFT_CS, TFT_DC, TFT_RST);
void setup() {
tft.init();
tft.fillScreen(ST7735_BLACK);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
}
void loop() {
tft.setCursor(0, 0);
tft.println("Hello, World!");
delay(1000);
}
```
### Example 2: Displaying BMP Image (Raspberry Pi with Python)
This example shows how to display a BMP image on the TFT LCD module using a Raspberry Pi and Python.
```python
import spidev
import os
# SPI setup
spi = spidev.SpiDev()
spi.open(0, 0)
# Display setup
WIDTH, HEIGHT = 160, 128
TFT_CS, TFT_RST, TFT_DC = 24, 25, 8
def tft_init():
spi.mode = 0b01
spi.max_speed_hz = 4000000
spi.cs0.set_active(0)
def tft_send_cmd(cmd):
spi.cs0.set_active(0)
spi.writebytes([cmd])
spi.cs0.set_active(1)
def tft_send_data(data):
spi.cs0.set_active(0)
spi.writebytes(data)
spi.cs0.set_active(1)
def display_bmp(image_path):
with open(image_path, 'rb') as f:
data = f.read()
tft_send_cmd(0x2A) # Case for command
tft_send_data([WIDTH >> 8, WIDTH & 0xFF, HEIGHT >> 8, HEIGHT & 0xFF])
tft_send_cmd(0x2C) # RAM write
tft_send_data(data)
tft_init()
display_bmp('path/to/image.bmp')
```
Note: The above examples are just a starting point and may require modifications to work with your specific setup and requirements.