TFT LCD (Thin film transistor liquid crystal display) adalah varian dari Liquid Crystal Display (LCD) yang menggunakan Transistor Film Tipis (TFT) teknologi untuk meningkatkan kualitas gambar seperti addressability dan kontras. TFT LCD matriks aktif LCD, berbeda dengan matriks pasif LCD atau sederhana, tampil dengan LCD dalam beberapa segmen. TFT LCD digunakan dalam peralatan termasuk televisi, monitor komputer, ponsel, video game portabel, PDA/Tablet, sistem navigasi dan proyektor.
- Arduino Uno
- TFT 1.8"
- Kabel Jumper male to male
- Projectboard
- Adafruit_GFX
- Adafruit_ST7735
Coding untuk scroll text / tulisan berjalan / running text sebagai berikut :
#include <Adafruit_GFX.h> // Include core graphics library
#include <Adafruit_ST7735.h> // Include Adafruit_ST7735 library to drive the display
#include <fonts/FreeSans9pt7b.h>
#include <fonts/FreeSans12pt7b.h>
#include <fonts/FreeSans18pt7b.h>
#include <fonts/FreeSans24pt7b.h>
// Declare pins for the display:
#define TFT_CS 10
#define TFT_RST 8 // You can also connect this to the Arduino reset in which case, set this #define pin to -1!
#define TFT_DC 9
// The rest of the pins are pre-selected as the default hardware SPI for Arduino Uno (SCK = 13 and SDA = 11)
// Create display:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#include <Fonts/FreeSerif18pt7b.h> // Add a custom font
int Variable1; // Create a variable to have something dynamic to show on the display
void setup() // Start of setup
{
// Display setup:
// Use this initializer if you're using a 1.8" TFT
tft.initR(INITR_BLACKTAB); // Initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_BLACK); // Fill screen with black
//tft.setRotation(0); // Set orientation of the display. Values are from 0 to 3. If not declared, orientation would be 0,
// which is portrait mode.
tft.setTextWrap(false); // By default, long lines of text are set to automatically “wrap†back to the leftmost column.
// To override this behavior (so text will run off the right side of the display - useful for
// scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored
// with setTextWrap(true).
tft.setTextColor(ST7735_WHITE); // White on black
tft.setTextSize(5); // large letters
tft.setRotation(1); // horizontal display
//tft.println("Hello");
} // End of setup
void scrolltext(int x, int y, const char *s, uint8_t dw = 1, const GFXfont *f = NULL, int sz = 1)
{
int16_t x1, y1, wid = tft.width(), inview = 1;
uint16_t w, h;
tft.setFont(f);
tft.setTextColor(YELLOW, BLACK);
tft.setTextSize(sz);
tft.setTextWrap(false);
tft.getTextBounds((char*)s, x, y, &x1, &y1, &w, &h);
// w = strlen(s) * 6 * sz;
for (int steps = wid + w; steps >= 0; steps -= dw) {
x = steps - w;
if (f != NULL) {
inview = wid - x;
if (inview > wid) inview = wid;
if (inview > w) inview = w;
tft.fillRect(x > 0 ? x : 0, y1, inview + dw, h, BLACK);
}
x -= dw;
tft.setCursor(x, y);
tft.print(s);
if (f == NULL) tft.print(" "); //rubout trailing chars
delay(5);
}
}
void loop()
{
scrolltext(0, 30, "Sekolah Robot Indonesia Mengucapkan Selamat Hari Raya Idul Fitri 1441 H , Mohon Maaf Lahir Dan Batin", 8, NULL, 6);
}
#include <Adafruit_ST7735.h> // Include Adafruit_ST7735 library to drive the display
#include <fonts/FreeSans9pt7b.h>
#include <fonts/FreeSans12pt7b.h>
#include <fonts/FreeSans18pt7b.h>
#include <fonts/FreeSans24pt7b.h>
// Declare pins for the display:
#define TFT_CS 10
#define TFT_RST 8 // You can also connect this to the Arduino reset in which case, set this #define pin to -1!
#define TFT_DC 9
// The rest of the pins are pre-selected as the default hardware SPI for Arduino Uno (SCK = 13 and SDA = 11)
// Create display:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#include <Fonts/FreeSerif18pt7b.h> // Add a custom font
int Variable1; // Create a variable to have something dynamic to show on the display
void setup() // Start of setup
{
// Display setup:
// Use this initializer if you're using a 1.8" TFT
tft.initR(INITR_BLACKTAB); // Initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_BLACK); // Fill screen with black
//tft.setRotation(0); // Set orientation of the display. Values are from 0 to 3. If not declared, orientation would be 0,
// which is portrait mode.
tft.setTextWrap(false); // By default, long lines of text are set to automatically “wrap†back to the leftmost column.
// To override this behavior (so text will run off the right side of the display - useful for
// scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored
// with setTextWrap(true).
tft.setTextColor(ST7735_WHITE); // White on black
tft.setTextSize(5); // large letters
tft.setRotation(1); // horizontal display
//tft.println("Hello");
} // End of setup
void scrolltext(int x, int y, const char *s, uint8_t dw = 1, const GFXfont *f = NULL, int sz = 1)
{
int16_t x1, y1, wid = tft.width(), inview = 1;
uint16_t w, h;
tft.setFont(f);
tft.setTextColor(YELLOW, BLACK);
tft.setTextSize(sz);
tft.setTextWrap(false);
tft.getTextBounds((char*)s, x, y, &x1, &y1, &w, &h);
// w = strlen(s) * 6 * sz;
for (int steps = wid + w; steps >= 0; steps -= dw) {
x = steps - w;
if (f != NULL) {
inview = wid - x;
if (inview > wid) inview = wid;
if (inview > w) inview = w;
tft.fillRect(x > 0 ? x : 0, y1, inview + dw, h, BLACK);
}
x -= dw;
tft.setCursor(x, y);
tft.print(s);
if (f == NULL) tft.print(" "); //rubout trailing chars
delay(5);
}
}
void loop()
{
scrolltext(0, 30, "Sekolah Robot Indonesia Mengucapkan Selamat Hari Raya Idul Fitri 1441 H , Mohon Maaf Lahir Dan Batin", 8, NULL, 6);
}