How To Use A TFT Screen - Arduino Project Hub
How To Use A TFT Screen - Arduino Project Hub
Sign In (https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FMisterBotBreak%2Fhow-to-use-a-tft-screen-8dbdaf)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 1/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
display (/projecthub/projects/tags/display)
potentiometer (/projecthub/projects/tags/potentiometer)
text (/projecthub/projects/tags/text)
k
V
G
%
0
A
)
JI
h
M
z
M
T
c
3
N
D
k
s
U
H
J
v
a
m
V
j
d
A
Y
6
B
k
V
G
%
0
A
)
×
(
/
p
r
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 7/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
r
Rotary potentiometer o
(generic) j
e 1
(/projecthub/products/buy/2
02? c (/proj (/projecthub/products
s=BAhJIhMzMTc3NDksUHJvam t ecthu /buy/202?
(/projecthub/pro VjdAY6BkVG%0A) h b/pro s=BAhJIhMzMTc3NDks
ducts/buy/202? u ducts UHJvamVjdAY6BkVG%
s=BAhJIhMzMTc3 b /buy/ 0A)
NDksUHJvamVjd / 202?
AY6BkVG%0A) p s=BAh
r JIhMz
o MTc3
d NDks
u UHJva
c mVjd
t AY6Bk
s VG%0
/ A)
b
u
y
/
2
0
2
?
s
=
B
A
h
JI
h
M
z
M
T
c
3
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 8/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
N
D
k
s
U
H
J
v
a
m
V
j
d
A
Y
6
B
k
V
G
%
0
A
)
Arduino IDE
(https://www.arduino.cc/en/main/ (https://www.arduino.cc/en/
(https://www.ar software) main/software)
duino.cc/en/mai
n/software)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 9/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
The TFT Screen is a touch screen. The screen that we will use a composed of 320p per
240p. Using this screen is pretty simple : you just have to design forms and text using
functions, such as :
tft.reset();
tft.begin(0x9341);
tft.fillScreen(BLACK);
tft.setRotation(1);
These functions reset the screen, color the screen in black, and set the screen into the
landscape mode.
tft.setCursor(5, 5);
tft.setTextColor(WHITE);
tft.setTextSize(1);
It prints the text ( after saying that the text have a color, a size and a cursor ).
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 10/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
tft.drawPixel(x, y, color);
It draws a line ( x1/y1 : first point coordinates ; x2/y2 : second point coordinates and
color.
It draws a filled circle with the color that we use ( x/y : center coordinates ; Radius and
color ).
It draws a simple circle ( same characteristics than the filled circle but this time the circle
isn't filled ).
It draws a simple rectangle ( x/y : one point of the rectangle ; x2 = x1+length of the
rectangle / y2 = y1 + width of the rectangle and color ).
It draws a filled rectangle ( same characteristics than the simple rectangle but the
rectangle is filled ).
It draws a rectangle with curved corners ( same characteristics than the rectangle but
here, c is the number of pixel that curved corners of the rectangle ).
Its draws a filled rectangle with curved corners ( same characteristics than the rounded
rectangle ).
Available colors :
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 11/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
Libraries
In this project we will use 2 libraries : Elegoo GFX and Elegoo TFTLCD.
Libraries can be download on the "Enclosures and Customs parts" area.
Code
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 12/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
#include <Elegoo_GFX.h>
#include <Elegoo_TFTLCD.h>
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
Elegoo TFTLCD tft(LCD CS, LCD CD, LCD WR, LCD RD, LCD RESET);
Connections
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 13/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
This screen is a shield so you just have to plug it on the Arduino Mega by following pins
definiton provided above.
CODE
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 14/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
2
1 #include <Elegoo_GFX.h>
3 #include <Elegoo_TFTLCD.h>
4
E
l
e
g
o
o
G
F DOWNLOAD (HTTPS://HACKSTERIO.S3.AMAZONAWS.COM/UPLOADS/ATTACHMENTS/1068595/ELEGOO_GFX
X
elegoo_gfx_jlrSAMddqy.zip
E
l
e
g
o
o
T
F
T
L
C
DOWNLOAD (HTTPS://HACKSTERIO.S3.AMAZONAWS.COM/UPLOADS/ATTACHMENTS/1068596/ELEGOO_TFT
D
elegoo_tftlcd_st5JGm3tNS.zip
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 15/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
COMMENTS
Phil D (/projecthub/philmnut)
9 months ago
(/pr
Thank
oject you MrBotBreak,
This
hub/is one of the devices I struggle to control. I will certainly study this article.
As
phil"they" say, "It's all about control." LOL
mnu
t)
MisterBotBreak (/projecthub/MisterBotBreak)
9 months ago
(/pr
Thank
oject for your comment. Sorry if my English is bad, I'm a foreigner.
hub/
Mist
erBo
tBre Phil D (/projecthub/philmnut)
ak) 9 months ago
(/pr
MisterBotBreak
oject
Ihub/
see you have quite a few projects on line, I too like electronics and always want
to
phillearn more. Please don't be sorry for poor English, I admire people who take on
cultural
mnu changes as you do learning English, I know only one language and do a
t)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 16/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
beachbum975 (/projecthub/beachbum975)
2 months ago
(/pr
Hi,
ojectI read your excellent project and wondered if you might offer some guidance on
ahub/
related topic of using TFT with SD. I am able to display input from sensor such as
potentiometer
beac on TFT. However, if I also save the sensor input to a txt or csv file
on
hbuSD card, I cannot succeed in sending the file data back to the TFT to display the
same
m97 data again. The txt or csv files save the data as strings, but I suspect the TFT
requires
5) analog input to reproduce the inital graph from the analog sensor. The
Arduino does not have a digital to analog converter, and there doesn't seem to be
a way to use PWM to simulate a DAC converter for this task. This implies that
there is no solution.
Or I may not understand the problem at all! Would appreciate your thoughts.
Mike
holualoa (/projecthub/holualoa)
8 months ago
(/pr
This
ojectis very helpful.
I'm
hub/trying to figure out how to change the font. I see the Adafruit version of libraries has
aholu
'tft.SetFont()' command, and the capability to load a few fonts. However, this
Elegoo_TFTLCD
aloa) and Elegoo_GFX don't seem to have any commands to alter the font.
Is this correct? What am I missing?
Thanks
MisterBotBreak (/projecthub/MisterBotBreak)
7 months ago
(/pr
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 17/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
ojecthave to use :
You
hub/
tft.fillScreen(color)
Mist
erBo
tBre
ak)
AUTHOR
(/projecthub/MisterBotBreak)
MisterBotBreak (/projecthub/MisterBotBreak)
25 PROJECTS 67 FOLLOWERS
FOLLOW (/PROJECTHUB/USERS/SIGN_UP?ID=527398&M=USER&REASON=FOLLOW&REDI
PUBLISHED ON
February 8, 2020
WRITE A COMMENT
Share
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 18/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
(/projecthub/createchweb/displaying-an-image-on-a-lcd-tft-screen-with-arduino-uno-
acaf48?ref=similar&ref_id=317749&offset=0)
(/projecthub/electropeak/arduino-2-4-touch-screen-lcd-shield-tutorial-fe6f05?
ref=similar&ref_id=317749&offset=1)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 19/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
(/projecthub/electropeak/ultimate-beginner-s-guide-to-run-tft-lcd-displays-by-
arduino-081006?ref=similar&ref_id=317749&offset=2)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 20/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
(/projecthub/Rjuarez7/rotary-scanner-using-arduino-mega2560-and-tft-dfbde4?
ref=similar&ref_id=317749&offset=3)
(/projecthub/LightPro/tft-graphing-3d-bar-charts-939222?
ref=similar&ref_id=317749&offset=4)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 21/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
(/projecthub/calogerus/arduino-uno-2-4-tft-lcd-display-shield-touch-panel-ili9341-
576b1b?ref=similar&ref_id=317749&offset=5)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 22/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
Arduino UNO + 2.4 TFT LCD Display Shield Touch Panel ILI9341
(/projecthub/calogerus/arduino-uno-2-4-tft-lcd-display-shield-
by calogerus (/projecthub/calogerus)
61,111 VIEWS 12 COMMENTS 46 RESPECTS
(https://www.arduino.cc)
Powered by
(https://www.hackster.io)
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 23/23