0% found this document useful (0 votes)
214 views23 pages

How To Use A TFT Screen - Arduino Project Hub

This document provides instructions on how to use a TFT screen with an Arduino. It describes connecting a TFT touchscreen and jumper wires to an Arduino board. The project will show how to display graphics, text, and read input from the touchscreen and a potentiometer on the TFT screen.

Uploaded by

Sergiu B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
214 views23 pages

How To Use A TFT Screen - Arduino Project Hub

This document provides instructions on how to use a TFT screen with an Arduino. It describes connecting a TFT touchscreen and jumper wires to an Arduino board. The project will show how to display graphics, text, and read input from the touchscreen and a potentiometer on the TFT screen.

Uploaded by

Sergiu B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

11/16/2020 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)

How to Use a TFT Screen


This project will show you how to use a TFT Screen.

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)

graphics (/projecthub/projects/tags/graphics) lcd (/projecthub/projects/tags/lcd)

potentiometer (/projecthub/projects/tags/potentiometer)

text (/projecthub/projects/tags/text)

3,794 VIEWS 6 COMMENTS 5 RESPECTS

COMPONENTS AND SUPPLIES 

TFT Touchscreen, 320x240


(/projecthub/products/buy/5
× 1 
4028?
( (/proj (/projecthub/products
s=BAhJIhMzMTc3NDksUHJvam
/ ecthu /buy/54028?
VjdAY6BkVG%0A)
p b/pro s=BAhJIhMzMTc3NDks
(/projecthub/pro
ducts/buy/5402 r ducts UHJvamVjdAY6BkVG%
8? o /buy/ 0A)
s=BAhJIhMzMTc3 j 5402
e 8?
NDksUHJvamVjd
c s=BAh
AY6BkVG%0A)
t JIhMz
h MTc3
u NDks
b UHJva
/ mVjd
p AY6Bk
r VG%0
o A)
d
u
c
t
s
/
b
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 2/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
b
u
y
/
5
4
0
2
8
?
s
=
B
A
h
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
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 3/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub

k
V
G
%
0
A
)

Male/Female Jumper Wires


(/projecthub/products/buy/4
× 1 
2773?
( (/proj (/projecthub/products
s=BAhJIhMzMTc3NDksUHJvam
/ ecthu /buy/42773?
VjdAY6BkVG%0A)
p b/pro s=BAhJIhMzMTc3NDks
(/projecthub/pro
ducts/buy/42773 r ducts UHJvamVjdAY6BkVG%
? o /buy/ 0A)
s=BAhJIhMzMTc3 j 42773
e ?
NDksUHJvamVjd
c s=BAh
AY6BkVG%0A)
t JIhMz
h MTc3
u NDks
b UHJva
/ mVjd
p AY6Bk
r VG%0
o A)
d
u
c
t
s
/
b
u
y
/
4
2
7
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 4/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub
7
7
3
?
s
=
B
A
h
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
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 5/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub

Arduino Mega 2560


(/projecthub/products/buy/14
× 1 
5?
( (/proj (/projecthub/products
s=BAhJIhMzMTc3NDksUHJvam
/ ecthu /buy/145?
VjdAY6BkVG%0A)
(/projecthub/pro p b/pro s=BAhJIhMzMTc3NDks
r ducts UHJvamVjdAY6BkVG%
ducts/buy/145?
o /buy/ 0A)
s=BAhJIhMzMTc3
j 145?
NDksUHJvamVjd
e s=BAh
AY6BkVG%0A)
c JIhMz
t MTc3
h NDks
u UHJva
b mVjd
/ AY6Bk
p VG%0
r A)
o
d
u
c
t
s
/
b
u
y
/
1
4
5
?
s
=
B
A
h
https://create.arduino.cc/projecthub/MisterBotBreak/how-to-use-a-tft-screen-8dbdaf 6/23
11/16/2020 How to Use a TFT Screen - Arduino Project Hub

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
)

APPS AND ONLINE SERVICES 

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

ABOUT THIS PROJECT 

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);

It set the cursor.

tft.setTextColor(WHITE);

It defines the color of the text.

tft.setTextSize(1);

It defines the text size.

tft.println("Kittens are cute !");

It prints the text ( after saying that the text have a color, a size and a cursor ).

tft.drawLine(x1, y1, x2, y2, color);

It draws a pixel ( x/y : coordinates of the pixel and color ).

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.

tft.fillCircle(x, y, radius, color);

It draws a filled circle with the color that we use ( x/y : center coordinates ; Radius and
color ).

tft.drawCircle(x, y, radius, color);

It draws a simple circle ( same characteristics than the filled circle but this time the circle
isn't filled ).

tft.drawRect(x, y, x2, y2, color);

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 ).

tft.fillRect(x, y, x2, y2, color);

It draws a filled rectangle ( same characteristics than the simple rectangle but the
rectangle is filled ).

tft.drawRoundRect(x, y, x2, y2, c, color);

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 ).

tft.fillRoundRect(x, y, x2, y2, c, color);

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 BLACK 0x0000


#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

CS, CD, WR, RD and RST pins definition :


For Arduino Mega/Uno :

#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

#define BLACK 0x0000


#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

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 

TFT Screen Arduino   (/PROJECTHUB/CODE_FILES/423763/DOWNLOAD)

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

CUSTOM PARTS AND ENCLOSURES 

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 

Please log in (/projecthub/users/sign_in?


id=317749&m=project&reason=comment&redirect_to=%2Fprojecthub%2FMisterBotBrea
k%2Fhow-to-use-a-tft-screen-8dbdaf%23comments) or sign up
(/projecthub/users/sign_up?
id=317749&m=project&reason=comment&redirect_to=%2Fprojecthub%2FMisterBotBrea
k%2Fhow-to-use-a-tft-screen-8dbdaf%23comments&source=popup) to comment.

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

poor job of using it.


Thanks again
philmnut
1 thank

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

 RESPECT PROJECT (/PROJECTHUB/USERS/SIGN_UP?ID=317749&M=ARTICLE&REASON=RESPECT&R...

 WRITE A COMMENT

 Share

MEMBERS WHO RESPECT THIS PROJECT

(/projecthub/MisterBotBreak) (/projecthub/safdar-afkari) (/projecthub/marco-

corsaro) (/projecthub/ziojean01) (/projecthub/ascot231)

SEE SIMILAR PROJECTS


YOU MIGHT LIKE

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

SIMILAR PROJECTS YOU MIGHT LIKE

(/projecthub/createchweb/displaying-an-image-on-a-lcd-tft-screen-with-arduino-uno-
acaf48?ref=similar&ref_id=317749&offset=0)

Displaying An Image On A LCD TFT Screen With Arduino UNO!


(/projecthub/createchweb/displaying-an-image-on-a-lcd-tft-
Project tutorial by CreaTechWeb (/projecthub/createchweb)
6,291 VIEWS 4 COMMENTS 9 RESPECTS

(/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

Arduino 2.4″ Touch Screen LCD Shield Tutorial


(/projecthub/electropeak/arduino-2-4-touch-screen-lcd-shield-
by ElectroPeak (/projecthub/electropeak)
17,959 VIEWS 3 COMMENTS 23 RESPECTS

(/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

Ultimate Beginner’s Guide to Run TFT LCD Displays by Arduino


(/projecthub/electropeak/ultimate-beginner-s-guide-to-run-tft-
by ElectroPeak (/projecthub/electropeak)
42,861 VIEWS 11 COMMENTS 60 RESPECTS

(/projecthub/Rjuarez7/rotary-scanner-using-arduino-mega2560-and-tft-dfbde4?
ref=similar&ref_id=317749&offset=3)

Rotary scanner using Arduino MEGA2560 and TFT


(/projecthub/Rjuarez7/rotary-scanner-using-arduino-mega2560-
Project tutorial by Rafa Juárez (/projecthub/Rjuarez7)
4,312 VIEWS 0 COMMENTS 5 RESPECTS

(/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

TFT Graphing: 3D Bar Charts (/projecthub/LightPro/tft-graphing-


3d-bar-charts-939222?ref=similar&ref_id=317749&offset=4)
Project tutorial by Andrei Florian (/projecthub/LightPro)
4,670 VIEWS 2 COMMENTS 22 RESPECTS

(/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

You might also like