arduino lcd touch screen 2.4 factory
In this tutorial, you will learn how to use and set up 2.4″ Touch LCD Shield for Arduino. First, you’ll see some general information about this shield. And after learning how to set the shield up, you’ll see 3 practical projects.
The role of screens in electronic projects is very important. Screens can be of very simple types such as 7 Segment or character LCDs or more advanced models like OLEDs and TFT LCDs.
One of the most important features of this LCD is including a touch panel. If you are about to use the LCD, you need to know the coordinates of the point you touch. To do so, you should upload the following code on your Arduino board and open the serial monitor. Then touch your desired location and write the coordinates displayed on the serial monitor. You can use this coordination in any other project.
To display pictures on this LCD you should save the picture in 24bit BMP colored format and size of 240*320. Then move them to SD card and put the SD card in the LCD shield. we use the following function to display pictures. This function has 3 arguments; the first one stands for the pictures name, and the second and third arguments are for length and width coordinates of the top left corner of the picture.
If you want to display pictures without using an SD card, you can convert it to code and then display it. You can display even several photos sequentially without delay to create an animation. (Check this) But be aware that in this case, Arduino UNO may not be suitable (because of low processor speed). We recommend using the Arduino Mega or Arduino DUE.
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.
In order the code to work and compile you will have to include an addition “.c” file in the same directory with the Arduino sketch. This file is for the third game example and it’s a bitmap of the bird. For more details how this part of the code work you can check my particular tutorial. Here you can download that file:
Ever wanted to know how to make a simple drawing program on a LCD display, or are you curious about programming touch screens? Well, in this tutorial, we will be covering on how do you program a touchscreen display using the 2.4″ Touchscreen LCD sheild with Arduino Uno, which open up many possible applications which includes making a user friendly touch interface for making purchases, a simple touch-screen base remote control, and many more.
Hooking up the 2.4″ TFT LCD Touchscreen shield is realatively easy, since it is a Arduino shield. Just plug in the whole screen into the Arduino Uno, just note where the pins are located and connect the shield accordingly. There will be 2 parts in this tutoria, the first where you will test the functionality of the screen, and the next where you test the touch functionality of the screen.
For the graphics test of the 2.4″ screen, I used the sample sketch provided by the Adafruit TFTLCD library. The library can be downloaded here or here. (NOTE: You have to have the Adafruit GFX library installed before this library is installed, as the TFTLCD library uses the Adafruit GFX library for graphics. The library can be downloaded at https://github.com/adafruit/Adafruit-GFX-Library) A great thanks to Adafruit for their libraries.
Try uploading the example ‘graphictest’ sketch of the TFTLCD library. The screen should then be running the graphics test as shown above. If the screen displays nothing or displays only static, you may want to follow the steps taken below.
The modification I made in the example sketch is that I hard coded the LCD Driver, as for my case, the Arduino was unable to detect the LCD driver (and only produced noise on the screen).
Therefore, I set identifier variable as 0x9341 (located at line 60), which means that the shield is actually using a IL9341 LCD driver. Below are some useful links that may help if you encounter any difficulties:
This is the hardcoded sketch. Please upload the ‘graphictest’ example sketch of the TFTLCD library. If there is static or no display, you may need to modify the ‘identifier’ variable depending on which LCD driver you are using. Below is a sample code of the LCD Driver hard coded.// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
Open & upload the ‘tftpaint’ example sketch from the TFTLCD library. (You may want to calibrate the screen first before using it. To do so, visit this post where I written a calibration code which can be used in this example. However, please note that certain parameters have to be changed for the calibration sketch to work with this 2.4″ screen.)
If the sketch does not run properly, you may want to do the following modifications. For my case, I need to modify a few parts, which includes:Hardcoding the LCD Driver
Spice up your Arduino project with a beautiful touchscreen display shield with built in microSD card connection. This IPS TFT display is 2.4" diagonal and colorful (18-bit 262,000 different shades)! 240x320 pixels with individual pixel control. As a bonus, this display has a optional capacitive touch panel and resistive touch panel with controller XPT2046 attached by default.
The shield is fully assembled, tested and ready to go. No wiring, no soldering! Simply plug it in and load up our library - you"ll have it running in under 10 minutes! Works best with any classic Arduino (UNO/Due/Mega 2560).
Of course, we wouldn"t just leave you with a datasheet and a "good luck!" - we"ve written a full open source graphics library at the bottom of this page that can draw pixels, lines, rectangles, circles and text. We also have a touch screen library that detects x,y and z (pressure) and example code to demonstrate all of it. The code is written for Arduino but can be easily ported to your favorite microcontroller!
1.2.4 inch arduino shield with resistive touch panel could only support Due board. It can support DUE,UNO,MEGA2560 boad if matched with capacitive touch panel.
2.If you"ve had a lot of Arduino DUEs go through your hands (or if you are just unlucky), chances are you’ve come across at least one that does not start-up properly.The symptom is simple: you power up the Arduino but it doesn’t appear to “boot”. Your code simply doesn"t start running.You might have noticed that resetting the board (by pressing the reset button) causes the board to start-up normally.The fix is simple,here is the solution.
The 2.4 ” tft lcd touch screen shield for Arduino can be used in a number of applications. However many of the shields available on the market are cloned versions which usually give many hobbyists hard time to use because they do not work properly with the common libraries for running TFT displays.
If you try uploading any of the examples in the Adafruit_GFX library for example the “graphicstest”, the lcd will just give a white screen. Nothing is displayed on the screen!
This problem is mainly due to using a newer version of the Adafruit GFX library. The 1.5.4 release of the Adafruit_GFX library broke compatibility with the Adafruit_TFTLCD library. So you have to roll back to Adafruit_GFX 1.5.3:
Another problem you may encounter with this tft lcd shield is the poor fuctioning of the touch screen. You may find the stylus pen is not well aligned with the content you are writing on the screen.
This is due to a bug in the TouchScreen library therefore you need to locate this library by following the path to where all the libraries for your Arduino IDE are stored.
First change it to return TSPoint(1023-x, 1023-y, z). Save the changes and then compile your code again and upload to check if the touch fuction is fine.
You can keep on adjusting the values of before x and y until you get an ideal point that works best for your tft lcd. Mine worked fine with return TSPoint(x, 1105-y, z)
Due to the limited processing power of the microprocessor in the Arduino, we need to store images in bmp format and they should be 320×240 pixels sizes.
Find the different arino touch screen and Alibaba.com products at wholesale prices. Find the wide wholesale suppliers on Alibaba.com to provide more products to your customers.
However, for arino touch panels that have tougher tactile elements, the screen suppliers may offer options that provide more information for a complex display of different products. Find an arino touch screen from wholesale suppliers on Alibaba.com to provide different products for your customers" needs.
There are four main types of arino touch screen: aruino lcdds. They give the user an option to display their products for a more natural-looking experience and at the same time. Now, when choosing the arinoino touch screen based on your consumers" needs and preferences. Hence, for your customers to choose the arino touch screen based on their preferences and the ones that are built with them.
The AZ-Delivery 2.4” TFT LCD Touch Display boasts 320x 240 pixels with 16-bit color. It has Touch capabilities, a built-in SD card drive, and plugs straight onto the top of an Arduino UNO or Mega. Amazon charges less than £11 for this device. It offers a major step up from the tiny SSD1306 128×64 monochrome display.
The TFT screen is much larger than the SSD1306 128×64 and much more colourful. The package includes an SD card reader on the underside and a stylus for accurate touch-screen control.
The underside of the board has labels on the pins. As the board is an Arduino shield, it will only fit on a UNO in one position. The SD card reader sits between USB and the power socket. It will also plug into and Arduino MEGA 2560. J1 and J2 fit into the digital pins, covering D0 to D13, while J3 and J4 fit into the analog and power pins.
I searched the Web for drivers and examples and found a great deal of praise for the TFT graphics, reports of problems with the Touch control and nothing about the SD card reader on this board.
In the end I installed several libraries (with all dependencies): Adafruit GFX, Adafruit TFTLCD, Adafruit TouchScreen, Adafruit ILI9341, MCUFRIEND_kbv and SPFD5408-master. (The last 2 are not essential but include some interesting examples). The SD library is included in the basic Arduino set.
I’ve used GFX with mono displays such as SSD1306 and soon got the TFT display working. The following script gives some idea about what it can do. I’ve included pixels, text (of varying sizes), lines, rectangles, triangles, squares, graphs, screen rotation, and text on a path. I was very impressed with the clarity, speed, brightness, and colors produced.
Normally, when setting the colour of an RGB LED you have a range of 0-255 (0-FF hex) for each RGB component which gives white = FFFFFF, red = FF000, green FF00 and blue = FF. This is 24-bit colour and takes 3 bytes. 224 gives 16,777,216 different colours. The TFT screen is a 16-bit colour device which can display 65,536 different colours – more than enough. Here the range is limited to 5 bits each for red and blue and 6 bits for green. (Our eyes are more sensitive to green so It gets the extra bit of accuracy.)
The following sketch gives an indication of the colours available by converting an array of 24-bit colour values into their 16-bit equivalent and displaying them on the screen with the data. There are not enough pixels on the screen to display all the colours at once so the last part of the sketch takes out the least significant green bit and displays half the available colours six ways.
Most Arduino users seldom use string manipulation. The documentation and a few simple examples of how to use strings are well scattered over the Web and difficult to find. The first sketch demonstrates how to create a file of 5 records/lines, each made up from an integer, a string, and a floating-point variable. The file is called datalog6.txt.
This is the part that often causes the most trouble with many owners giving up at this point. It may be because there are several different configurations of the pins used to connect to the touch layers of the screen on the many varied breakout boards and shields using this display. In this case four of the pins are used, at different times, to control both the graphics or the touch elements of the screen.
This is a resistive touch screen, rather than a capacitive one. Above the graphics, layers are two transparent resistive layers held apart by tiny dimples. One is connected at the top and bottom and the other at the sides. A potential difference is applied across them and when the stylus or a finger presses on the screen an electrical connection is made between the resistive layers.
The Analog pins are used to measure the voltages at that point on the two resistive layers, one at a time, in the same manner as we read the voltage from the wiper of a potentiometer – a potential divider. Using these values, it is possible to calculate, quite accurately, the coordinates of the point on the screen where the pressure has been applied. Calibration is often needed to improve accuracy. Adafruit suggests reading the resistance across the X plate (XP = D8 and XM = A2). On my board, I got 341 Ohms. Use this value as SENSITIVITY.
Try running the sketch to draw on the screen. The BLACK palette ‘button’ clears the screen and the others change the ‘ink’ colour. If the dot drawn is not directly under the stylus you can adjust the ‘fudge factors’ in the scaling section.
As a final example here is a sketch which shows off the Touch screen with buttons, bar graphs and colours. The buttons allow the user to adjust the RGB mix to display all the possible colours available. If you find one you particularly like it displays the hex value of the 16-bit colour.
There is a small amount of jitter as the bar graph re-draws but overall, the shield works quickly and very well. After the screen has updated and waiting for a touch the image is steady, sharp, and bright. Once you have calibrated the touch device it is very accurate as demonstrated with the small (30×30 pixel buttons) and provides excellent, colorful graphics on a usefully large display.
I was very pleased with the quality of the display and the accuracy of the Touch device. It sits neatly and securely on a UNO or a MEGA 2560. With an SD card reader included it was excellent value and I will be making good use of it in the future.
Usually customer-oriented, and it"s our ultimate focus on to be not only by far the most reliable, trustable and honest provider, but also the partner for our customers for Touch Screen Display For Arduino, Lcd Numeric Display Modules, Lcd Screen Module, Lcd Touch Screen Kiosk,Wide Temperature Customize Tft Lcd Module. We have been wanting ahead to setting up cooperative associations along with you. Make sure you contact us for more data. The product will supply to all over the world, such as Europe, America, Australia,Kuwait, Burundi,Rio de Janeiro, Seattle.There are advanced producing & processing equipment and skilled workers to ensure the products with high quality. We have found an excellent before-sale, sale, after-sale service to ensure the customers that could rest assured to make orders. Until now our products are now moving on fast and very popular in South America, East Asia, the Middle east, Africa, etc.
General Specification NMLCD-24QA is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and with a Resistive Touch...
NMLCD-24240320-RTP is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and with a ...
General Specification NMLCD-24240320 is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a backlight unit and with/without a...
General Specification NMLCD-24240320-CLB is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and without a Touch...
NMLCD-24240320-CLB is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and without a Touch...
General Specification NMLCD-24240320-RTP is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and with a...
General Specification NMLCD-24QA is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and with a Resistive Touch...
NMLCD-24240320 is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and without a Touch...
General Specification NMLCD-24240320 is a colour active matrix LCD module incorporating amorphous silicon TFT (Thin Film Transistor). It is composed of a colour TFT-LCD panel, driver IC, FPC and a back light unit and without a Touch...
I"ll show you how to get started with a very popular variant of the TFT touch screen, including how to make a "button" (spoiler alert: it"s not a button just an area of screen that looks like one, that you can then receive touches from).