Arduino XPT2046 Touchscreen Calibration and Coding - ILI9341 LCD with XPT2046 Touch screen

preview_player
Показать описание
A touchscreen makes a great user interface for your Arduino projects. The LCD panel lets you create dials, and instruments that you can then control using buttons, sliders and anything else you want to code.

In this tutorial I'll show you how to write a simple calibration function so you can quickly map your touchscreen data to the screen coordinates and then show you how to monitor for touch events and create a simple user interface button.

You can easily get hold of one of these touchscreens at Amazon or eBay.

Make sure you have a look at my setup and animation tutorials to get your panel up and running.

Setup

Animation

All the code for this tutorial is available on the project page in my website.
Рекомендации по теме
Комментарии
Автор

I am sure that someone has informed you that the code on your webpage won't run. The fault is that when it was copied over the <, >, and && coded as lg;, gt; and &amp; respectively.
Weird 😁, It had me stumped for an hour then it dawned on to compare the code in the video to the one on your webpage. Runs great now. Good explanations, good video series....Thanks!!!

gnather
Автор

Bob, I don't know what is going on but the files you have put on your website for us to download are nothing like what you show us here, this file on your site has the setup in the wrong place half way through the script and the script does not match what you show on here, Also some of your other script files have C++ code in them which will not run in the Arduino IDE, Pretty abysmal really and I am thinking you don't care as I have messaged you twice and you have not bothered to respond. Bob. UK

stoptheirlies
Автор

This is amazing. It completely breaks down the calibration of a TFT display. After this, I don't need to watch another video on calibrating TFT's.
I'm subscribing too!

danielewusi-essel
Автор

loving these videos - thanks.
I have a problem compiling this example as it says "lt, gt etc not defined. Can you help please.
Problem fixed. I just read Hal's post further down.

pw
Автор

Hey thanks for your help! I still have some issues with my screen. When i try to draw the Block its now folloring my pen, its like that the stick is stuck on the top left corner of the screen...

padesmo
Автор

I copied the "Touchscreen Calibration Code" from your website and discovered via the compiler that at least ten lines had garbled contents. For instance, line 50 reads:
if(xCoord &lt; 0) xCoord = 0;
but it should read, according to the code in the video;
if (xCoord < 0) xCoord = 0;
It seems that a (less than symbol) "<" is supplanted with " &lt; " and the (greater than) ">" symbol is supplanted with " &gt; ".

Also line 128;
ScreenPoint sp = ScreenPoint();
differs slightly from that shown in your video presentation where it appears as;
ScreenPoint sp = ScreenPoint(0, 0);
After I made the corrections the compiler was happy and the program ran beautifully, just like in the video. Line 128 seems to work just fine with or without the "0, 0".
Your presentation was masterful in explaining how and why touchscreen calibration is done. Thank you very much.

Just wondering if the garbling was done because of international travel?

halalbach
Автор

Finally found a video that explained the code. Thank you for putting this video on youtube.
Do you have more video? I want to learn to use TFT function to draw graphics.

jumbo
Автор

sometimes im not sure why mine.. need to do calibration evertime i reconnect/power on my device

DanialADHOfficial
Автор

I wish you a good day. I was thinking about your codes. I've tried almost all of the programs from the library. Everything works. Only those codes that you published during the calibration gave me an error at the end of the code. And when I tried the touch screen drawing program, it said chiba somewhere in the middle. Please some advice. Well thank you.

atihrot
Автор

Dear Mr. Those codes don't work for me at all. I can't run drawing on the LCD. Can you help me?

atihrot
Автор

I have always relied on a single point to determine the screen offset in my code. This one point provides enough information to obtain both the X and Y offsets.

PeetHobby
Автор

Dear Mr. Those codes don't work for me at all. I can't run drawing on the LCD. Can you help me?

atihrot
Автор

Can u plz tell me how to add this TFT display in Proteus for simulation purpose ?? Can u plz give it exact library link where I can download it

bhagyashrirajput
Автор

Very good explained touch calibration. The const have to put in eeprom variables after first calibration.

viktorhugo
Автор

Very well explained and easy to follow.

My touchscreen draws both red targets before even touching the screen.
Somehow it thinks it was touched after the first target and goes past the line "while(!ts.touched());"
Then it waits at the 2nd target and that one seems to work, but the first one not working invalidates the calibration.

confirmed this with some Serial.print debug text.

Using "TouchTest.ino" the Pressure reading is 321 when not touched and around 2000 when touched.

mevmevmev
Автор

Im having a hard time understanding where the "20 - " value is coming from. I understand that y=mx+b that is where we cross the x/y axis, but in terms of this example I dont quite understand how you came to the value of 20. Can you please explain?

JerrygOnRoblox
Автор

Thank you for a great series of videos. You've put a lot of work into them, and I appreciate that greatly. I have been trying to get my display to work for several days, came across your videos, and had it working in 30 minutes. Could I perhaps suggest that you put the words XPT2046 and ILI9341 in the title of the videos, I was searching for a long time before finding them! Thanks again.

funky
Автор

Thanks for the video on ILI9341 with XPT2046 touch screen. I am making a project with following details
Arduino DUE

TFT CS 52
TFT DC 3
TFT RST -1
TFTbrightness DAC0
T CS 36
T IRQ 34
MISO 62
MOSI 63
SCK 64

I am also using SD card module. It's MISO, MOSI & SCK connection are connected to 62, 63 & 64 respectively.

Due to project limitations, I cannot change pin number. Everything things is working except Touch.

I am using ILI9341_due_config.h, ILI9341_due.h, XPT2046_Touchscreen.h.

Pls. help me to enable touch of the display.

vivekrohella
Автор

Good morning. I have this screen "3.5inch TFT Touch Shield (320x480 Pixel / XPT2046 Touch controller)" and I want to connect it to Arduino uno R3… I want to connect the DHT11 & MQ-3 sensors and control them from the screen but see temperature / humidity / Gas. I tried according to the video but it only shows me a white screen. Please if you can help me. Thanks in advance!

vzfqsnf