On top of the button we will print the text using the big font and the same background color as the fill of the button. Then we will set the color back to white and using the drawRoundRect() function we will draw another rounded rectangle on top of the previous one, but this one will be without a fill so the overall appearance of the button looks like it has a frame. First we need to set the color and then using the fillRoundRect() function we will draw the rounded rectangle. After that we need to set the color back to white, and print the two other strings, “by ” using the small font and “Select Example” using the big font. Next we will set the color to red and draw the red line below the text. ![]() Then we need to set the color to white, set the big font and using the print() function, we will print the string “Arduino TFT Tutorial” at the center of the screen and 10 pixels down the Y – Axis of the screen. With the setBackColor() function we need to set the background color of the text, black one in our case. So now I will explain how we can make the home screen of the program. SelectedUnit = '0' // Indicates the selected unit for the first example, cms or inches Defining Pin Modes pinMode(VCC, OUTPUT) // VCC pinMode(trigPin, OUTPUT) // Sets the trigPin as an Output pinMode(echoPin, INPUT) // Sets the echoPin as an Input pinMode(redLed, OUTPUT) ĭigitalWrite(VCC, HIGH) // +5V - Pin 13 as VCCĭrawHomeScreen() // Draws the Home ScreenĬurrentPage = '0' // Indicates that we are at Home Screen = Defining Variables extern uint8_t SmallFont # include # include //= Creating Objects UTFT myGLCD (SSD1289, 38, 39, 40, 41) //Parameters should be adjusted to your Display/Schield model URTouch myTouch ( 6, 5, 4, 3, 2) In the setup section we need to initiate the screen and the touch, define the pin modes for the connected sensor, the led and the button, and initially call the drawHomeSreen() custom function, which will draw the home screen of the program. Next we need to define the fonts that are coming with the libraries and also define some variables needed for the program. The parameters of these objects depends on the model of the TFT Screen and Shield and these details can be also found in the documentation of the libraries. You can download these libraries from his website, and also find a lot of demo examples and detailed documentation of how to use them.Īfter we include the libraries we need to create UTFT and URTouch objects. The libraries enable really easy use of the TFT Screens, and they work with many different TFT screens sizes, shields and controllers. Here I would like to say thanks to him for the incredible work he has done. ![]() I will use the UTFT and URTouch libraries made by Henning Karlsen. And at the end of this article I will post the complete source code. As an Amazon Associate I earn from qualifying purchases.Īs the code is a bit longer and for better understanding I will post the source code of the program in sections with description for each section. Amazon / Banggood / AliExpressĭisclosure: These are affiliate links. Arduino Board …………………………… Amazon / Banggood / AliExpress. ![]() TFT Display Mega Shield……………… Amazon / Banggood / AliExpress.You can get these components from any of the sites below: ![]() Also I had to make a custom made pin header like this, by soldering pin headers and bend on of them so I could insert them in between the Arduino Board and the TFT Shield. For the first example I have the HC-SR04 ultrasonic sensor, then for the second example an RGB LED with three resistors and a push button for the game example. We need a shield because the TFT Touch screen works at 3.3V and the Arduino Mega outputs are 5 V. Parts needed for this Arduino Touch ScreenĪs an example I am using a 3.2” TFT Touch Screen in a combination with a TFT LCD Arduino Mega Shield. Now we will go through each of these examples and step by step explain the codes behind them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |