1.8-inch Color Touchscreen
Module Source
Purchase Link: https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-23991449512.20.62ae703buie1Ei&id=568584833602
Baidu Netdisk Download Link: https://pan.baidu.com/s/1n_vp38V7ij88PUGpbJPd7Q
Password: 8888
Specifications
Operating Voltage: 3.3V
Operating Current:30MA
Module Dimensions:35(H) x 56(V) MM
Pixel Resolution:128(H) x 160(V)RGB
Driver Chip:ST7735S
Communication Protocol:SPI
Pin Count:12 Pin (2.54mm pitch header)
With resistive touch chip: XPT2046
Hardware Connection
- TFT_CS (Chip Select): Connect to digital pin 10 on the development board.
- TFT_RST (Reset): Connect to digital pin 9 on the development board. Sometimes this pin can be directly connected to the reset pin of the board or permanently connected to VCC if the screen always resets when powered on.
- TFT_DC (Data/Command): Connect to digital pin 8 on the development board.
- TFT_MOSI (Master Out Slave In): Connect to digital pin 11 on the development board (corresponding to the hardware SPI MOSI pin).
- TFT_SCLK (Serial Clock): Connect to digital pin 13 on the development board (corresponding to the hardware SPI SCK pin).
- TFT_MISO (Master In Slave Out): If the screen supports reading data from the Arduino board, connect to digital pin 12 on the development board (corresponding to the hardware SPI MISO pin). Not all TFT screens require this connection.
- VCC: Connect to 5V or 3.3V on the development board, depending on the voltage requirements of the screen.
- GND: Connect to GND on the development board.
- T_CS: Connect to digital pin 6 on the development board.
- PEN: This pin is optional and is used for touch interrupt signals. If the interrupt feature is not used, it can be left unconnected.
Usage Method
Installing Library Files (skip this step if already installed)
- Open the Arduino IDE.
- Go to “Tools” > “Manage Libraries…”.
- Search for “Adafruit ST7735”, “ThingPulse XPT2046 Touchand” and “Adafruit GFX”, and install each library individually.
Enter the code:
Next, write the following code in the .ino file:
c
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: March 26, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <XPT2046_Touchscreen.h>
// Define the SPI pins for the ST7735 screen
#define TFT_CS 10
#define TFT_RST 9 // Can be set to 9 or connected to the Arduino's Reset pin
#define TFT_DC 8
// Define the SPI pins for the STMPE610 touchscreen
#define STMPE_CS 6
#define TS_IRQ 2
XPT2046_Touchscreen ts(STMPE_CS, TS_IRQ);
// Initialize Adafruit_ST7735 library
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
void setup(void) {
Serial.begin(9600);
tft.initR(INITR_GREENTAB); // Initialize the screen
tft.fillScreen(ST7735_BLACK); // Clear screen to black
ts.begin();
ts.setRotation(1);
tft.setTextWrap(false); // Set text to not automatically wrap
tft.setRotation(0); // Set rotation
tft.fillScreen(ST7735_BLACK); // Clear screen to black
tft.setTextColor(ST7735_WHITE); // Set text color to white
tft.setTextSize(1); // Set text size
tft.setCursor(0, 0); // Set the starting position of the text
tft.print("Hello, World!"); // Set displayed text
}
void loop() {
if (ts.tirqTouched()) {
if (ts.touched()) {
TS_Point p = ts.getPoint();
tft.fillRect(0,30,50,77,ST7735_BLACK);
tft.setCursor(0, 30); // Set the starting position of the text
tft.print("x = ");
tft.print(p.x); // Set displayed text
tft.setCursor(0, 60); // Set the starting position of the text
tft.print("y = ");
tft.print(p.y); // Set displayed text
delay(5);
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70