A Professional Manufacturer of Smart Interactive Screens For More Than 10 Years
The Tft touch screen is an amazing graphical interface that can be used with the arduino of the MCU.
It has a wide range of colors, good graphics capabilities and good pixel maps, and can be used in applications that require graphic drawing, image viewing, and monitoring of large volumes of output (
Such as simulation value, temperature, distance, voltage, etc. . . etc. )and much more.
There are a lot of tft modules out there and what I get, what I'm going to use here is ITEAD STUDIO. . 2. Monthly ITDB02 status.
This is a project for arduino UNO, what I'm going to show here is how to use it in MEGA.
The program stores memory for a very ridiculous reason.
This is the sheild I'm going to use here: originally made for arduino UNO boards, but it works with mega.
There are two main problems when using uno, storage memory and pin usage!
It is difficult to use unused pins (by the screen)
Because all the pins are covered with the lid!
We use better giant boards.
It should be noted that this module can be used 3.
Ofcurse on Uno or mega can provide a 3 or 5 V voltage, we can use a 5 V voltage, and the booth in it can operate at a 5 V voltage.
In order for sheild to be available on the she board, we need the following hardware: arduino mega tft 2. 8 LCD (itead studio)
Software: arduino IDE can open any program for C, C, and Header (. h)files . .
Here is (CODE :: BLOCKS)
And the UTFT library, you can use its ancillary features such as UTocuh Lib.
Next, I will show how to edit utft lib to use tft uno sheild on mega.
UTFT Lib is a very good library for driving a large number of tft screen modules.
Include our modules.
After installing the library, you should see something similar to the first image.
These are the documents of the library.
This library is a big one that requires about 30 kB of arduino flash memory!
This is too much for arduino uno!
With this library, you can add almost anything to your code.
MEGA has 256kb of program memory, which is very good space to do very good things with it, in addition, there are 54 pins, most of which are still free to use, only 5 simulations are 16.
This is usually enough for most projects.
After you download the library, you need to open its file and edit something in it!
Open the UTFT library file to see what is similar to the first picture, then open the folder named "hardware" and you should see the family of the mcu (
ARM and pic32)
Mega and uno came from the avr family, so we opened it up.
Now you should see the mcu using arduino (ie.
Atmega uses atmeg328p)
You can see a header file called "hw_avr _ definitions. . .
This is our goal. .
Open it with some programs (
Code: block is used here.
A quick tip is that the UTFT Library is a very large lib that runs based on the motherboard or mcu used and the defined modules.
The main utft file calls the definition of the hardware based on your entry, so when you select from the tool-board---> Arduino mega.
It calls it the definition of arduino mega to understand the pin connection to the module you sell.
What we're going to do here is edit something in the library that will allow you to use the right defense when using uno sheild.
The Utft Library developer adds this feature to the library and all we have to do is enable it.
We can do this before: 1.
Open the file named "hw_avr _ definitions" 2.
You should see something like pic23.
Read the note at the beginning of codeline 6 stating that you should "uncomment the following lines to enable this feature" 4.
Uncomment on line 7, which makes the definition of mega sheild on mega possible. 5. save and exit. 6.
Move or copy the library file to the aruino IDE Library Directory (
Suppose you know how to do it: 3)
Now we have done this!
Next, we will show how to use the library and define the pins on mega.
After editing the library and adding it to the arduino directory.
You should be able to include it in your program.
Now I will show you how to define the correct tft module in your hand.
The tft screen we use is named on Module 2.
We should find its module name in the library, open the library file and go to the document, you should see three files. This file shows all the features and commands contained in this library.
The Utft _ requirement this file has information about the module and its relationship with the library, such as pin configuration _ support _ Display _ module _ & _ controller this is our goal, this file has the names of the modules and sheilds supported by this library, where you can see the list of module names and module names for UTFT, which you should use to define the modules.
Our module is called 2.
We found its name: ITDB28, which is what we are going to use.
Now, to define the utft object on the arduino ide, we use the command: UTFT name (
Modules, Rs, Wr, Cs, Rst);
The witch is mintiond in UTFT. pdf file.
We should give this object a name, we call it myGLCD, then we give this module a name, we find it called ITDB28 I will not explain what these pins are (
This is indicated in the data sheet and utft _ requirement. pdf file)
But you should know that it is on the A5, A4, A3 and A2 pins for this sheild.
When you open an example included in the library, you get a note about which pins you should use, and don't forget to use arduino uno sheild on the mega board!
So we define it as a very direct, simulated name (A5-A2).
The final command is: UTFT myGLCD (
ITDB28, A5, A4, A3, A2);
Note that pins 19,18, 17,16 in arduino uno are pins A5, A4, A3, a2. relatively.
Now you are ready to use the screen!
: DLet print an example, HELLO world.
Here is the code: the edits to the definition of the main UTFT Library are also included in the attachment, to use the touch function on the screen, we can use the UTouch Library. You can download the library from quick
The link in step 1, just add it to the directory and then you can find some examples of using it.
From the example on the arduino ide, open the UTouch list and then open the example named "calibration.
We need to make some edits to the code, remember that we use arduino shesheild on the jumbo board!
For the UTFT definition, as in the previous step, you need to make some changes to the UTouch object definition, you will see the is in the comment, to use the arduino uno board, the configuration should be called :(15,10,14,9,8 )
This configuration is valid for arduino uno (
Pin 15 = A1 and pin 14 = 0)
For another module, the pins 9 and 8 of this module are reversed!
Keep in mind that we use the mega board, which is the correct configuration for this situation :(A1,10,A0,8,9)
Just change to the correct configuration and upload the code!
You should see the output in the pic on the screen.
In fact, this code is used to calibrate the screen. according to the instructions on the screen, you will get the results of the test. this is x, y calibration. you can check the source code of the utft Library, find these parameters and edit them!
However, this is not an essential thing, but it should make your touch coordination more accurate!
In the image, this is a test of the tft screen with the "Utouch quickPaint" example.
It's all here, imagine what you can do with these screens and features with these free pins and memory! on mega board!