Description
The?1.8 TFT?is a colorful?display?with 128 x 160 color pixels. The?display?can load images from an SD card ? it has an SD card slot at the back.
The 1.8 TFT is a brilliant showcase with 128 x 160 shading pixels. The showcase can stack pictures from a SD card ? it has a SD card space at the back
This module utilizes SPI correspondence ? see the wiring beneath . To control the presentation we’ll utilize the TFT library, which is now included with Arduino IDE 1.0.5 and later
The TFT show speaks with the Arduino through SPI correspondence, so you need to remember the SPI library for your code. We likewise utilize the TFT library to compose and draw on the presentation
#include <TFT.h>
#include <SPI.h>
At that point, you need to characterize the CS, A0 (or DC) and RST pins:
#define cs 10
#define dc 9
#define rst 8
Make an example of the library called TFTscreen:
TFT TFTscreen = TFT(cs, dc, rst);
At long last, in the arrangement(), you need to instate the library:
TFTscreen.begin();
Show text
Show text
To compose text on the showcase, you can redo the screen foundation tone, text dimension and shading.
To set the foundation tone, use:
TFTscreen.background(r, g, b);
In which, r, g and b are the RGB esteems for a given tone. To pick text style tone:
TFTscreen.stroke(r, g, b);
To set the text dimension:
TFTscreen.setTextSize(2);
You can increment or reduction the number given as contention, to increment or diminishing text dimension.
At last, to draw text on the presentation you utilize the accompanying line:
TFTscreen.text(“Hello, World!”, x, y);
In which “Hi, World!” is the content you need to show and the (x, y) organize is where you need to begin show text on the screen
Code
The following example displays ?Hello, World!? in the middle of the screen and changes the font color every 200 miliseconds.
/*
* Rui Santos
* Complete Project Details https://randomnerdtutorials.com
*/
// include TFT and SPI libraries
#include <TFT.h>
#include <SPI.h>
// pin definition for Arduino UNO
#define cs?? 10
#define dc?? 9
#define rst? 8
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
void setup() {
//initialize the library
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
//set the text size
TFTscreen.setTextSize(2);
}
void loop() {
//generate a random color
int redRandom = random(0, 255);
int greenRandom = random (0, 255);
int blueRandom = random (0, 255);
// set a random font color
TFTscreen.stroke(redRandom, greenRandom, blueRandom);
// print Hello, World! in the middle of the screen
TFTscreen.text(“Hello, World!”, 6, 57);
// wait 200 miliseconds until change to next color
delay(200);
}
Customer Reviews
There are no reviews yet.