This post explains about how to display text on TFT lcd using arduino uno? TFT which is used in the tutorial is 2.4′ TFT by Mcufriend. It has ST7781 controller in it, Driver code is ST7783. This 2.4 inch TFT Lcd is arduino compatible. It can easily be mounted on an Arduino uno board. This TFT can be interfaced in 32,16 and 8 bit parallel mode. It also supports I2c Mode. In this tutorial i am going to interface it in 8-bit parallel mode with arduino uno.
Struggle – Finding TFT Lcd driver
Project code is below. I am not using any predefined library for displaying text on TFT lcd, I actually didn’t find any library that can properly display text on the TFT i have, all the libraries through which i have gone through were unable to initialize my lcd driver properly. So i decided to first read the driver of the TFT and then write my own code according to the driver supported commands. I first read the TFT Driver. To learn about how to check the TFT Lcd driver just go through this small tutorial.
Successful TFT Lcd driver identified
After reading the driver of TFT i went through its datasheet. The TFT which i have is working with ST7781 controller, it’s a Chinese manufactured TFT by Mcufriend, their website says that the TFT is working on ILI9321 driver but its not. The information on ther website is misleading everyone, I have seen many posts on internet that talks about the Mcufriend TFT Lcd driver. So if you have a TFT and you are unable to find its driver than go through the above tutorial.
The TFT used in the tutorial is shown below.
The TFT use in project can easily be mounted on any Arduino board. I mounted it on Arduino uno. You can also use any other Arduino board but for that you have to make changes in the code.
Arduino TFT project code
Changing the code is not a hard task if you understand the code written below. Coming to the Code. I first initialized the TFT Controlling pins LCD_RST, LCD_CS, LCD_RS, LCD_WR, LCD_RD. In the Setup function I made the Port-D and Port-B of Arduino Uno as output Port. Since the data pins of TFT is interfacing with Port-D and Port-B of Arduino so to write data and commands to TFT we have to declare Port-D and Port-B as output. Then the function InitializeTFT() is initializing the TFT.
Functions defined in the code – purpose and meaning
InitializeTFT() is Initializing TFT.
IndexRegister() Specifying the index of the register.
CommandData() Sending Commands and Data to TFT Driver.
fastDisplay() Displaying Data on lcd very Fast.
TftPaint() Painting TFT with the Specified Color.
PaintLcd() Calling the TftPAint() Function.
IndexRegister() Specifying the index of the register.
CommandData() Sending Commands and Data to TFT Driver.
fastDisplay() Displaying Data on lcd very Fast.
TftPaint() Painting TFT with the Specified Color.
PaintLcd() Calling the TftPAint() Function.
In the Loop function i am filling TFT with colours. Colors are filled in Horizontal and vertical directions. According to the data sheet which says you can display text on TFT in eight directions.
- Vertical_Bottom_Horizontal_RIGHT
- Vertical_Bottom_Horizontal_LEFT
- Vertical_Top_Horizontal_RIGHT
- Vertical_Top_Horizontal_LEFT
- Horizontal_Bottom_Horizontal_RIGHT
- Horizontal_Bottom_Horizontal_LEFT
- Horizontal_Top_Horizontal_RIGHT
- Horizontal_Top_Horizontal_LEFT
The configuration of display is set in the register 03 of the driver. For full description of register 03 please read the datasheet.
The Code above will fill TFT with colors and the code below is displaying text “www.microcontroller-project.com” on TFT. Try to first understand the above code before moving to the code below. Above code is simply a method to fill the pixels of TFT. If you grabbed the process of filling TFT Pixels than you can display any text on lcd by manipulating the pixels.
Download the arduino project code. Folder contains the Arduino ide project .ino file. If you have any queries please write them below in the comments section.
Filed Under: Arduino, Microcontroller Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.