Introduction: Using Tft Itead 2.8 Arduino UNO Sheild on MEGA

Picture of Using Tft Itead 2.8 Arduino UNO Sheild on MEGA

Tft touch screens are amazing graphical interface that could be used with MCU's specially arduino.

It has wide color range, and good graphical ability and good map of pixels , can be used in applications that needs graph plotting, images viewing, monitorring numerous outputs (such as analog values, temperature , distance, voltage ... etc.) and much more.

There are alot of tft modules out there, the one I got and I gonna use here is ITEAD STUDIO .. 2.8 ITDB02 SHEILD.

It's a sheild for arduino UNO, what I gonna show here is how to use it with MEGA. for a very loggical reason ,, the PROGRAM STORAGE MEMORY .

Step 1: The Tft Screen

Picture of The Tft Screen

This is the sheild I gonna use here :

https://www.itead.cc/itead-2-8-tft-lcd-touch-shield.html


its originally made for the arduino UNO boards, but it can be used with mega. there are two main problems while using it with the uno, the storage memory, and the pins usage! It,s hard to use the unused pins (by the screen) because all the pins are coverd with the sheild! for that resons we use better the MEGA board.

You should note that this module can be use 3.3 or 5 volt to supply , ofcurse on uno or mega, we can use 5v while booth of them are operate at 5V.

To make the sheild useable with the mega board, we will need the following :

HARDWARE :



• arduino mega
• tft 2.8 LCD (itead studio)


SOFTWARE :



• arduino IDE
• any program that can open the C,C++ and Header(.h) files ..
the one used here is (CODE :: BLOCKS)
• and the UTFT Library
• and you can use it's accessorize such as, UTocuh Lib.


in the next step I gonna show how to edit the utft lib to use the tft uno sheild on mega.

Step 2: Edit UTFT Library

Picture of Edit UTFT Library

the UTFT Lib is very good library that is used to drive a large number of tft screens modules. our module is included.

after you have installed the library, you should see something like the first image. these are the files of the library.

this library is one of the big libraries, it takes about 30kb of the arduino flash memory! this is too much for arduino uno! you can almost add nothing to the code with this library.

the MEGA has 256kb of program memory, this is very good space and can do very good things with it, in addition, there are 54 pin most of them still free to use, and the analog just 5 are taken of 16. this is most often more that enough for most projects.

after downloading the library, you need to open it's files, and edit something in it!

open the UTFT library file to see something similar to the first pic, then open the folder named "hardware", you should see the families of the mcu's (AVR,ARM and pic32) the mega and uno are from the avr family, so we open it.

now you should see the arduino's mcu that uses(ie. the uno uses the Atmega_328p ) and you can see a header file named "HW_AVR_defines" ... this is our target.. open it with some program (CODE :: BLOCKs is used here).

one quick hint, the UTFT Library is very big lib that operates depending on the board or mcu that's used, and the module that is defined. the main utft file call the definitions of the hardware depending on your entries , so when you choose from tools-board---> arduino mega . it call the defintions of the arduino mega, to know the pins connection to the module you have sellected too.

what we gonna do here, is to edit something in the library that make the mega, uses the right defentions when you use an uno sheild with it. The utft library developer add this feature to the library, all we have to do, is to enable it.

we can do so by :



1. open the file with the name "HW_AVR_defines"
2. you should see something like pic2
3. read the note at the start of the code
line 6 says that you should "Uncomment the following line to enable this feature"
4. uncomment the line 7, that enable the defintions of uno sheild on mega.
5. save and exit.
6. move or copy the library file to the aruino IDE libraries directory (suppose you know how to do it :3 )


now we are done with this step! in the next step we gonna show how to use the library and define the pins on the mega.

Step 3: Define the Tft Lcd

Picture of Define the Tft Lcd

after you have edited the library and added it to the arduino directory. you should be able to include it in your programs.

now i gonna show you how to define the right tft module that you have in your hand.

the tft screen that we used is named on the module 2.8 ITDB02 we should find its module name in the library, open the library file and go to the documentation , you should see three files



• UTFT
this file show all the functions and commands that included in this library.
• UTFT_Requirement
this file has the information about the modules and how it's related to the library, like pins configurations
•UTFT_Supported_display_modules_&_controller
this is our target, this file has the names of the modules and sheilds that is supported by this library, you can see in it a list of module names and module names for the UTFT which you should use to define your module.
our module named 2.8 ITDB02 ,, looking for it we find the name : ITDB28 and this is what we gonna use.




now to define an utft object on the arduino ide, we use the command :

UTFT name(module,Rs,Wr,Cs,Rst); witch is mintiond in the UTFT.pdf file.

we should give a name to the object, lets call it as example "myGLCD"

then we name the module, which we found it called ITDB28 , then we sellect the pins, i'm not going to explain what these pins are(it's noted in the data sheet and UTFT_Requirement.pdf file), but you should know that for this sheild, it's located on the A5,A4,A3 and A2 pins.

when you open one of the examples that's included in the library, you will get a note about what pins you should use, don't forget that you use arduino uno sheild, on mega board!

so we gonna define it very direct, as the analog name (A5-A2).

the final command is :

UTFT myGLCD(ITDB28,A5,A4,A3,A2);
# note that pins, 19,18,17,16 in the arduino uno are the pins A5,A4,A3,A2. relatively.
Now you are ready to use the screen! :D

Step 4: HELLO WORLD!

Let's print as an example, HELLO world .
this is the code :

// main code from Rinky-Dink Electronics, Henning Karlsen.
// web: http://www.RinkyDinkElectronics.com/ // edited by : Motaz bany amer // // This program requires the UTFT library. //

#include <UTFT.h>

// Declare which fonts we will be using extern uint8_t BigFont[]; extern uint8_t SevenSegNumFont[];

// Remember to change the model parameter to suit your display module! UTFT myGLCD(ITDB28, A5, A4, A3, A2);

void setup() { myGLCD.InitLCD(); myGLCD.clrScr(); myGLCD.setFont(BigFont); } void loop() { myGLCD.setColor(0, 255, 0); //green myGLCD.print("HELLO WORLD", 45, 100); while (true) {}; }

Step 5: Touch Test!

Picture of Touch Test!

the edit on the main UTFT Library definition also ablied to the accessories, to use the touch feature in the screen we can use the UTouch library
you can download the library from the quick-link in the first step, just add it to the directory, then you can find some examples to use it.
from the examples lest on the arduino ide open the UTouch list then open the example named "calibration".
we need to do some edit to the code, remember that we use arduino uno sheild on the mega board!
for the UTFT definition, just do as the previous step, for the UTouch object definition, there ia are some change you need to make, you see the is in the note, to use arduino uno board, you should call the configuration :
(15,10,14,9,8 )
this configuration is valid for arduino uno (pin 15 = A1 and pin 14 = A0) and further more for another module, this module has the pin 9 and 8 reversed!
keeping in mind that we use mega board, the correct configuration that valid to this case :
(A1,10,A0,8,9)
just change to the correct configuration and upload the code!
you should see have the output in the pic on your screen.
actually, this code is used for calibrate the screen, after following the instruction on the screen, you will get the result of the test, it's the x,y calibration, you can ooen the utft library source code , find those parameters and edit them! however it's not essential thing to do, but it suppose to give you more accuracy whit your touch coordinations!

in the image this is a test of the tft screen with "Utouch quickPaint" example.

Step 6: Done!

this is all here, imagine what can you do with such screen and features with all these free pins and memory! on mega board!

good luck, hope this was usefull ^^

Comments

AntonioC249 (author)2017-05-31

Hallo from germany.I have a little problem , my tft stays white . I have uncommented the Mega board definition. But I don´t know wihtch modul name i must write in the

UTFT
myGLCD(??????, A2, A1, A3, A4); the pins are the right i have it from
the datasheed and also they write my driver is ILI9341 Bus: 8 bit. But
in the pdf from utft i cant find a 2,8" ili9341.

any solutions ?

thanks Tony

ZackH5 (author)2016-12-05

I tried all of those steps, and the LCD stays in white. What could've gone wrong?

Motaz Bany-Amer made it! (author)ZackH52016-12-05

first I have to ask you, are you sure you have uncommented the Mega board definition of the mega board in "HW_AVR_defines" library, and saved your edit!. can you tell me if the LCD worked before or is this the first try?

if you are sure you have followed the steps correctly, then I only can presume that there is a disconnection or some damage in your tft.. to check this.

..

please try to use another arduino board, you can use an uno board or mega.

if possible please try to use another LCD

..

please try to press a little hard on the area marked with red in the picture, there might be a disconnection in these pins or beneath, it happens, and it happens to me once.

..

I had this kind of problem many times, most often I find the error in the pins set.. so please double check it.

..

one last thing I can think of, that you are using a different module from the one I used in this instructable, if so you have to change the model name "model for utft()" and you might need to change the pins set too.

..

please tell me if any thing worked with you :D

ZackH5 (author)Motaz Bany-Amer2016-12-05

Thanks for the fast reply.

1. I am sure the Mega board definition uncommented.

2. This is the first try.

3. I think my connection is enough (1st & 2nd pic).

4. I have no uno.

5. Attached is my 2.8 TFT shield. I think it is the same model (3rd & 4th pic).

Motaz Bany-Amer (author)ZackH52016-12-09

sorry for late reply this time :3

..

I only can thing that the module is different from mine.. to check
please give me the source you got your ocd from .. please post some link ..

I see pins names are commentet on your lcd..
in the utft library files
you should find some pdf files, please look inside them to find the pins decleration of the tft modules ..
please check if thery mach the ones on your lcd module..
if you give me the link I think I can look it for you ..

ZackH5 (author)Motaz Bany-Amer2016-12-14

Thanks for reply :)

I bought the lcd here:

http://www.lelong.com.my/2-8-inch-tft-lcd-display-...

Well, it is a bit different than the one I bought from same store.

As long as it works, then I don't really care about the color and pcb traces.

I do have the pdf files, the utft library works for any kind of TFT?

Since I don't know its ID, I don't where to refer.

Motaz Bany-Amer (author)ZackH52016-12-23

the module that you're using is differentthat mine, I looked in the documentation of the library i'm using, I couldn't find it.

I did some search and found these videos using the same module you are using and saying it is working! please check these videos .

and don't forget to look in the description and comments especially for the first video.

please notice that your module product company is mcufriend, mine is ITEAD studio.

please let me know if that helps!

mrgw98 (author)2016-03-14

That should work, thanks! Can't wait! Ordering it soon! You do not know how long I have been looking for something like this! To be honest I haven't looked very hard but I did look, haha.

mrgw98 (author)2016-03-13

I really needed this, thank you. This might be an obvious question but by ant chance can it work with Raspberry Pi 3? If it does not fit exactly will it work with extensions?

Motaz Bany-Amer (author)mrgw982016-03-14

hey, glad this was helpfull to you.
sorry, I never used the raspberry bi !
referring to library notes the writer doesn't made it for raspberry bi! however I beleive it works with it, but Iam sorry I have no idea about it!

mrgw98 (author)Motaz Bany-Amer2016-03-14

It is fine, thanks again though!

Motaz Bany-Amer (author)mrgw982016-03-14

i can suggest something! maybe you can use the arduino mega to drive the tft, and connect it to the raspberry bi by serial or something, this way you can uss the function of the pi and the the easy drive of the mega!
:D

alireza0000 (author)2016-03-13

thats nice

About This Instructable

4,413views

20favorites

License:

Bio: motaz bany-amer!! jordan 2/7/1994 Yarmouk university - jordan work at Genotronex lab, IEEE YU Robotics Team, YES yarmouk engineering students, hijjawy art engineers. =-=-=-=-=-=-=-=-=-=-=-=-=-=-= facebookhttps ... More »
More by Motaz Bany-Amer:Arduino: Pushing the Limits || Power-plugin timer.Arduino: pushing the limits || Arduino Timers.Using tft itead 2.8 arduino UNO sheild on MEGA
Add instructable to: