1.ดาวน์โหลด และติดตั้ง Library
ติดตั้ง Library
ArduinoIDE > Sketch > Include Library > Add .ZIP Library > หาไฟล์ที่ดาวน์โหลด
2.ต่ออุปกรณ์
.png?alt=media&token=b485ccfb-f114-4266-b2e9-aff36eca0440)
LCD TFT 1.8 > Arduino UNO
RST>7CS>6DC>5SDA>11SCL>13GND>GNDVCC>5V
2.ลงโปรแกรม
Copy โค้ดด้านล่าง
Arduino
1#include <Adafruit_GFX.h>
2#include <Adafruit_GC9A01A.h>
3
4#define TFT_CS 6
5#define TFT_RST 7
6#define TFT_DC 5
7
8Adafruit_GC9A01A tft = Adafruit_GC9A01A(TFT_CS, TFT_DC, TFT_RST);
9
10void setup() {
11 tft.begin();
12 tft.setRotation(0);
13 tft.fillScreen(GC9A01A_BLACK);
14
15 displayMainText();
16 displaySubText();
17}
18
19void loop() {
20}
21
22void displayMainText() {
23 tft.setTextSize(4);
24 tft.setTextColor(GC9A01A_MAGENTA);
25 int16_t x1, y1;
26 uint16_t w, h;
27
28 tft.getTextBounds("Ampify", 0, 0, &x1, &y1, &w, &h);
29 tft.setCursor((240 - w) / 2, 80);
30 tft.print("Ampify");
31
32 tft.setTextSize(5);
33 tft.setTextColor(GC9A01A_CYAN);
34 tft.getTextBounds("Shop", 0, 0, &x1, &y1, &w, &h);
35 tft.setCursor((240 - w) / 2, 140);
36 tft.print("Shop");
37}
38
39void displaySubText() {
40 tft.setTextSize(1);
41 tft.setTextColor(GC9A01A_YELLOW);
42 int16_t x1, y1;
43 uint16_t w, h;
44
45 tft.getTextBounds("www.shop.snp-inno.com", 0, 0, &x1, &y1, &w, &h);
46 tft.setCursor((240 - w) / 2, 200);
47 tft.print("www.shop.snp-inno.com");
48} 1#include <Adafruit_GFX.h>
2#include <Adafruit_GC9A01A.h>
3
4#define TFT_CS 6
5#define TFT_RST 7
6#define TFT_DC 5
7
8Adafruit_GC9A01A tft = Adafruit_GC9A01A(TFT_CS, TFT_DC, TFT_RST);
9
10void setup() {
11 tft.begin();
12 tft.setRotation(0);
13 tft.fillScreen(GC9A01A_BLACK);
14
15 displayMainText();
16 displaySubText();
17}
18
19void loop() {
20}
21
22void displayMainText() {
23 tft.setTextSize(4);
24 tft.setTextColor(GC9A01A_MAGENTA);
25 int16_t x1, y1;
26 uint16_t w, h;
27
28 tft.getTextBounds("Ampify", 0, 0, &x1, &y1, &w, &h);
29 tft.setCursor((240 - w) / 2, 80);
30 tft.print("Ampify");
31
32 tft.setTextSize(5);
33 tft.setTextColor(GC9A01A_CYAN);
34 tft.getTextBounds("Shop", 0, 0, &x1, &y1, &w, &h);
35 tft.setCursor((240 - w) / 2, 140);
36 tft.print("Shop");
37}
38
39void displaySubText() {
40 tft.setTextSize(1);
41 tft.setTextColor(GC9A01A_YELLOW);
42 int16_t x1, y1;
43 uint16_t w, h;
44
45 tft.getTextBounds("www.shop.snp-inno.com", 0, 0, &x1, &y1, &w, &h);
46 tft.setCursor((240 - w) / 2, 200);
47 tft.print("www.shop.snp-inno.com");
48}
