3.2 tft lcd touch screen expansion shield in stock
In this Arduino touch screen tutorial we will learn how to use TFT LCD Touch Screen with Arduino. You can watch the following video or read the written tutorial below.
For this tutorial I composed three examples. The first example is distance measurement using ultrasonic sensor. The output from the sensor, or the distance is printed on the screen and using the touch screen we can select the units, either centimeters or inches.
The third example is a game. Actually it’s a replica of the popular Flappy Bird game for smartphones. We can play the game using the push button or even using the touch screen itself.
As an example I am using a 3.2” TFT Touch Screen in a combination with a TFT LCD Arduino Mega Shield. We need a shield because the TFT Touch screen works at 3.3V and the Arduino Mega outputs are 5 V. 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. 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.
Here’s the circuit schematic. We will use the GND pin, the digital pins from 8 to 13, as well as the pin number 14. As the 5V pins are already used by the TFT Screen I will use the pin number 13 as VCC, by setting it right away high in the setup section of code.
I will use the UTFT and URTouch libraries made by Henning Karlsen. Here I would like to say thanks to him for the incredible work he has done. The libraries enable really easy use of the TFT Screens, and they work with many different TFT screens sizes, shields and controllers. You can download these libraries from his website, RinkyDinkElectronics.com and also find a lot of demo examples and detailed documentation of how to use them.
After we include the libraries we need to create UTFT and URTouch objects. 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.
Next we need to define the fonts that are coming with the libraries and also define some variables needed for the program. 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.
So now I will explain how we can make the home screen of the program. With the setBackColor() function we need to set the background color of the text, black one in our case. 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. Next we will set the color to red and draw the red line below the text. After that we need to set the color back to white, and print the two other strings, “by HowToMechatronics.com” using the small font and “Select Example” using the big font.
Now we need to make the buttons functional so that when we press them they would send us to the appropriate example. In the setup section we set the character ‘0’ to the currentPage variable, which will indicate that we are at the home screen. So if that’s true, and if we press on the screen this if statement would become true and using these lines here we will get the X and Y coordinates where the screen has been pressed. If that’s the area that covers the first button we will call the drawDistanceSensor() custom function which will activate the distance sensor example. Also we will set the character ‘1’ to the variable currentPage which will indicate that we are at the first example. The drawFrame() custom function is used for highlighting the button when it’s pressed. The same procedure goes for the two other buttons.
So the drawDistanceSensor() custom function needs to be called only once when the button is pressed in order to draw all the graphics of this example in similar way as we described for the home screen. However, the getDistance() custom function needs to be called repeatedly in order to print the latest results of the distance measured by the sensor.
Ok next is the RGB LED Control example. If we press the second button, the drawLedControl() custom function will be called only once for drawing the graphic of that example and the setLedColor() custom function will be repeatedly called. In this function we use the touch screen to set the values of the 3 sliders from 0 to 255. With the if statements we confine the area of each slider and get the X value of the slider. So the values of the X coordinate of each slider are from 38 to 310 pixels and we need to map these values into values from 0 to 255 which will be used as a PWM signal for lighting up the LED. If you need more details how the RGB LED works you can check my particular tutorialfor that. The rest of the code in this custom function is for drawing the sliders. Back in the loop section we only have the back button which also turns off the LED when pressed.
I puzzled some hours with exactly the same hardware setup and made a quick & dirty, but successfully test script, combining LCD, Touch and SD Card Features.
{"id":1860100849722,"title":"3.2\" inch TFT LCD 5V Expansion Shield Touch Screen with Touch Pen for Arduino","handle":"3-2-inch-tft-lcd-5v-expansion-shield-touch-screen-with-touch-pen-for-arduino","description":"\u003cstrong\u003eDescription:\u003c\/strong\u003e\u003cbr\u003e\n\u003cul\u003e\n\u003cli\u003eThis is a 3.2 inch TFT touch screen expansion board using standard Arduino Shield interface and it has good compatibility.\u003c\/li\u003e\n\u003cli\u003eIt integrates a 3.2-inch touch screen, I2C temperature sensor, TF card holder, level conversion circuit, and the secondary development is easy.\u003c\/li\u003e\n\u003cli\u003eWith GPRS module, you can design your Arduino phone.\u003c\/li\u003e\n\u003cli\u003eWith NFC reader module, you can create access control systems with the photos show.\u003c\/li\u003e\n\u003cli\u003eWith voltage and current sensor, you can make oscilloscope.\u003c\/li\u003e\n\u003cli\u003eCan use it directly to display characters, graphics and BMP format images. And touch controlling is available;\u003c\/li\u003e\n\u003cli\u003eCompatibility: As the SD card is connected to SPI pins of ICSP interface, compatible with Arduino UNO R3 \/ Arduino Mega2560 \/ Arduino Leonardo\u003c\/li\u003e\n\u003cli\u003eTouch screen type: resistive touchscreen.\u003c\/li\u003e\n\u003cli\u003eTouch Pen: length is 9cm;\u003c\/li\u003e\n\u003cli\u003eResolution: 240X400;\u003c\/li\u003e\n\u003cli\u003eDisplay size: 3.2 inch;\u003c\/li\u003e\n\u003cli\u003eOperating voltage: 5V;\u003c\/li\u003e\n\u003cli\u003eLogic level: 5V \/ 3.3V;\u003c\/li\u003e\n\u003cli\u003eOn-board 3.3V \/ 300mA regulator circuit;\u003c\/li\u003e\n\u003cli\u003eOperating current: the maximum is 150mA\u003c\/li\u003e\n\u003cli\u003eUse the A0 ~ A3 pins, D4 ~ D13 pins. And I2C interface, D0 \/ D1 \/ D2 \/ D3 is available, please refer to the product schematics for the details.\u003c\/li\u003e\n\u003cli\u003eOnboard Micro SD slot, support Micro SD \/ TF Card;\u003c\/li\u003e\n\u003cli\u003eOnboard LM75 temperature sensor: default I2C address is 0X48, scale is -55 ~ 125"C\u003c\/li\u003e\n\u003cli\u003eVery suitable for digital photo frame, oscilloscope, function generator, detection system monitor\u003c\/li\u003e\n\u003cli\u003eSize: 9*5.3cm\/3.54\"*2.09\"\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cbr\u003e\u003cstrong\u003ePackage Included:\u003c\/strong\u003e\u003cbr\u003e1*Shield\u003cbr\u003e1*Touch pen","published_at":"2018-08-27T17:43:00+08:00","created_at":"2018-08-27T17:44:52+08:00","vendor":"diymore","type":"LCD Display Module","tags":["Arduino","Display","Shield","UNO R3"],"price":1399,"price_min":1399,"price_max":1399,"available":true,"price_varies":false,"compare_at_price":null,"compare_at_price_min":0,"compare_at_price_max":0,"compare_at_price_varies":false,"variants":[{"id":18399800459322,"title":"Default Title","option1":"Default Title","option2":null,"option3":null,"sku":"X30543","requires_shipping":true,"taxable":false,"featured_image":null,"available":true,"name":"3.2\" inch TFT LCD 5V Expansion Shield Touch Screen with Touch Pen for Arduino","public_title":null,"options":["Default Title"],"price":1399,"weight":30,"compare_at_price":null,"inventory_management":null,"barcode":"","requires_selling_plan":false,"selling_plan_allocations":[]}],"images":["\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/1_225.jpg?v=1588654828","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/2_740.jpg?v=1588654828","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/3_365.jpg?v=1588654828","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/4_536.jpg?v=1588654828","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/5_682.jpg?v=1588654828","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/7_161.jpg?v=1588654828","\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/6_276.jpg?v=1588654828"],"featured_image":"\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/1_225.jpg?v=1588654828","options":["Title"],"media":[{"alt":"3.2 Inch Tft Lcd 5V Expansion Shield Touch Screen With Pen For Arduino Display Module","id":6678764879943,"position":1,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/1_225.jpg?v=1588654828"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/1_225.jpg?v=1588654828","width":1000},{"alt":"3.2 Inch Tft Lcd 5V Expansion Shield Touch Screen With Pen For Arduino Display Module","id":6678764912711,"position":2,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/2_740.jpg?v=1588654828"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/2_740.jpg?v=1588654828","width":1000},{"alt":"3.2 Inch Tft Lcd 5V Expansion Shield Touch Screen With Pen For Arduino Display Module","id":6678764945479,"position":3,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/3_365.jpg?v=1588654828"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/3_365.jpg?v=1588654828","width":1000},{"alt":"3.2 Inch Tft Lcd 5V Expansion Shield Touch Screen With Pen For Arduino Display Module","id":6678764978247,"position":4,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/4_536.jpg?v=1588654828"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/4_536.jpg?v=1588654828","width":1000},{"alt":"3.2 Inch Tft Lcd 5V Expansion Shield Touch Screen With Pen For Arduino Display Module","id":6678765011015,"position":5,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/5_682.jpg?v=1588654828"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/5_682.jpg?v=1588654828","width":1000},{"alt":"3.2 Inch Tft Lcd 5V Expansion Shield Touch Screen With Pen For Arduino Display Module","id":6678765109319,"position":6,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/7_161.jpg?v=1588654828"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/7_161.jpg?v=1588654828","width":1000},{"alt":"3.2 Inch Tft Lcd 5V Expansion Shield Touch Screen With Pen For Arduino Display Module","id":6678765240391,"position":7,"preview_image":{"aspect_ratio":1.0,"height":1000,"width":1000,"src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/6_276.jpg?v=1588654828"},"aspect_ratio":1.0,"height":1000,"media_type":"image","src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0122\/7558\/0986\/products\/6_276.jpg?v=1588654828","width":1000}],"requires_selling_plan":false,"selling_plan_groups":[],"content":"\u003cstrong\u003eDescription:\u003c\/strong\u003e\u003cbr\u003e\n\u003cul\u003e\n\u003cli\u003eThis is a 3.2 inch TFT touch screen expansion board using standard Arduino Shield interface and it has good compatibility.\u003c\/li\u003e\n\u003cli\u003eIt integrates a 3.2-inch touch screen, I2C temperature sensor, TF card holder, level conversion circuit, and the secondary development is easy.\u003c\/li\u003e\n\u003cli\u003eWith GPRS module, you can design your Arduino phone.\u003c\/li\u003e\n\u003cli\u003eWith NFC reader module, you can create access control systems with the photos show.\u003c\/li\u003e\n\u003cli\u003eWith voltage and current sensor, you can make oscilloscope.\u003c\/li\u003e\n\u003cli\u003eCan use it directly to display characters, graphics and BMP format images. And touch controlling is available;\u003c\/li\u003e\n\u003cli\u003eCompatibility: As the SD card is connected to SPI pins of ICSP interface, compatible with Arduino UNO R3 \/ Arduino Mega2560 \/ Arduino Leonardo\u003c\/li\u003e\n\u003cli\u003eTouch screen type: resistive touchscreen.\u003c\/li\u003e\n\u003cli\u003eTouch Pen: length is 9cm;\u003c\/li\u003e\n\u003cli\u003eResolution: 240X400;\u003c\/li\u003e\n\u003cli\u003eDisplay size: 3.2 inch;\u003c\/li\u003e\n\u003cli\u003eOperating voltage: 5V;\u003c\/li\u003e\n\u003cli\u003eLogic level: 5V \/ 3.3V;\u003c\/li\u003e\n\u003cli\u003eOn-board 3.3V \/ 300mA regulator circuit;\u003c\/li\u003e\n\u003cli\u003eOperating current: the maximum is 150mA\u003c\/li\u003e\n\u003cli\u003eUse the A0 ~ A3 pins, D4 ~ D13 pins. And I2C interface, D0 \/ D1 \/ D2 \/ D3 is available, please refer to the product schematics for the details.\u003c\/li\u003e\n\u003cli\u003eOnboard Micro SD slot, support Micro SD \/ TF Card;\u003c\/li\u003e\n\u003cli\u003eOnboard LM75 temperature sensor: default I2C address is 0X48, scale is -55 ~ 125"C\u003c\/li\u003e\n\u003cli\u003eVery suitable for digital photo frame, oscilloscope, function generator, detection system monitor\u003c\/li\u003e\n\u003cli\u003eSize: 9*5.3cm\/3.54\"*2.09\"\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cbr\u003e\u003cstrong\u003ePackage Included:\u003c\/strong\u003e\u003cbr\u003e1*Shield\u003cbr\u003e1*Touch pen"}
This is a 3.2 inch TFT touch screen expansion board using standard Shield interface and it has good compatibility. It integrates a 3.2-inch touch screen, I2C temperature sensor, TF card holder, level conversion circuit, and the secondary development is easy.
- The TFT LCD PCB adapter for Mega is compatible with the Arduino pins, the user can directly connect the TFT LCD PCB - Adapter on the shield and stand on the Arduino board. It can be used with a Mega2560 and LCD screen.
Fully assembled 3.2inch display with 320x240 pixels TFT LCD and a resistive touch overlay. Just plug it on top of ODROID-C1. 2x13 tall female header is already soldered on the PCB.