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

  Рет қаралды 29,701

Bytes N Bits

Bytes N Bits

Күн бұрын

Пікірлер: 77
@71Elizabeth_Bergman
@71Elizabeth_Bergman 13 күн бұрын
Arg, blew the traces on my 9341 board; new 7789 SDTouchSylusTFT arived today. Good thing is all your examples are funtioning save the SPI pins are 50-53 on the ArduinoMega which is easy to re-code. The mega loads the lcd,sd,&touch funtionality with 87% memory left plus 48 pins for say in my case flight control sensors. Thank you for your lectures and getting under the hood with these touchscreens❤
@BytesNBits
@BytesNBits 13 күн бұрын
Good to hear you're getting it working.
@danielewusi-essel219
@danielewusi-essel219 3 жыл бұрын
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!
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi Daniel. Thanks for the comments and I'm glad you found it useful. Thanks for the sub!
@deepraman8392
@deepraman8392 Ай бұрын
I enjoy your starting animation more than the video 😁
@BytesNBits
@BytesNBits Ай бұрын
I did make some videos on coding that game if you fancy having a go. Look for the Space Commander series.
@gnather
@gnather 2 жыл бұрын
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 & 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!!!
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. Thanks for the bug report. The Wordpress editor has issues with the code dumps. The newer videos are sorted out. I'll have to go back and fix this one.
@semirdzhyan
@semirdzhyan Жыл бұрын
@@BytesNBits I second this. Just came across your website and I tried using the calibration code posted there by copying/pasting it. Got the same errors mentioned by @gnather. I'm now going over your video to see where it differs from the posted code and hopefully get the calibration up and running.
@jumbo999614
@jumbo999614 3 жыл бұрын
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.
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi. I've got a short series on using the LCD screen from simple graphics up to coding a game. Have a look at the Arduino playlist kzbin.info/www/bejne/p3_KhZ15mNtsrK8
@viktorhugo8252
@viktorhugo8252 Жыл бұрын
Very good explained touch calibration. The const have to put in eeprom variables after first calibration.
@BytesNBits
@BytesNBits Жыл бұрын
Yes. That will save you having to recalibrate each time you start up. Or just hard code them into your project after you've got the values.
@PeetHobby
@PeetHobby Жыл бұрын
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.
@BytesNBits
@BytesNBits Жыл бұрын
A single point will give you a reasonable result but doesn't allow you to explicitly measure the offsets and scaling factors. On these small screen sizes any errors you introduce will probably be hard to notice.
@halalbach1855
@halalbach1855 3 жыл бұрын
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) "" 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?
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi. Thanks for spotting that. I'll have a look. The < changing to &lt; looks like an html thing.
@johnvine5731
@johnvine5731 2 жыл бұрын
It might be a browser problem. The browser cannot display the 'greater than' and 'less than symbols' . So, instead of < and >, the browser displays &lt and &gt. It happened to me as well.
@MHTSAPAS
@MHTSAPAS Жыл бұрын
@@BytesNBits It's been a year mate. What's the point of a tutorial when it's left with open holes. You need to fix or remove that code.
@pw3111
@pw3111 2 жыл бұрын
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.
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. The web code viewer is not working very well on this page. It's translated the < and > symbols into their html codes. lt should be .
@funky7823
@funky7823 3 жыл бұрын
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.
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi Gavin. Great to hear it helped. Good idea on the title changes.
@mevmevmev
@mevmevmev 2 жыл бұрын
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.
@BytesNBits
@BytesNBits 2 жыл бұрын
I'd try putting a delay in the startup code before it tries to see the first touch. It might be getting a false positive as it starts.
@larrybud
@larrybud Жыл бұрын
Ever get this working? I'm trying to get this touchscreen working with a pico and all I get are false positives. Bought a 2nd display thinking it might be hardware but it does the same thing. I had no problem getting the display portion working.
@mevmevmev
@mevmevmev 11 ай бұрын
@@larrybud I had to put the project aside. Hoping to get back to it at some point.
@coby1kenobii
@coby1kenobii 4 жыл бұрын
love the animations!
@BytesNBits
@BytesNBits 4 жыл бұрын
Thanks
@padesmo
@padesmo 2 ай бұрын
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...
@BytesNBits
@BytesNBits 2 ай бұрын
Can you see the data coming from the touchscreen changing as you move it around? Can you draw to the screen correctly? Test each part separately to make sure they are working and then try combining them back together to see where the fault lies.
@padesmo
@padesmo 2 ай бұрын
@@BytesNBits I guess I know what the problem is, I need to put a ton of pressure on the bottom left corner. I need to put the Z-Threadholt up to 1000 for no error inputs of the screen but then the corner doesn't work... Maybe the panel ist broke or something
@ПетърЧуклев-м4ч
@ПетърЧуклев-м4ч Жыл бұрын
Благодарим ви!
@BytesNBits
@BytesNBits Жыл бұрын
You're welcome
@DanialADHOfficial
@DanialADHOfficial Жыл бұрын
sometimes im not sure why mine.. need to do calibration evertime i reconnect/power on my device
@BytesNBits
@BytesNBits Жыл бұрын
If you're using my code it's programmed to go through the setup process each time. You'd need to modify the code to save the setup info to a file or something so the values are preserved between boots.
@atihrot755
@atihrot755 2 жыл бұрын
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.
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. The code on the web page has gotten corrupted by the website display. If you replace the &lt; and &gt; codes with < and > it should work. I'll try and update the code listing over the next few days.
@atihrot755
@atihrot755 2 жыл бұрын
Dear Mr. Those codes don't work for me at all. I can't run drawing on the LCD. Can you help me?
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. Your best bet is to try each part of the project separately. Make sure you can get the LCD panel working. Then try the basic touch screen functions and then try putting it all together.
@bhagyashrirajput3357
@bhagyashrirajput3357 3 жыл бұрын
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
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi. I don't use Proteus so I don't know if there is a package. Good luck in finding one :)
@rompipelotas
@rompipelotas Жыл бұрын
THANKS A LOT !!!!!!
@BytesNBits
@BytesNBits Жыл бұрын
no problem.
@Jerryg225OnRoblox
@Jerryg225OnRoblox 2 жыл бұрын
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?
@BytesNBits
@BytesNBits 2 жыл бұрын
Is the 20 for the block size values? That's just so I can easily change the size of the on screen square that is drawn where you touch the screen. It's not part of the calibration code.
@ThePrintHouse
@ThePrintHouse 2 жыл бұрын
@@BytesNBits xCalC and yCalC has 20- and I don't understand that (it is part of the calibration value). Where do you get the 20 from? Why is that due to the size of the square? I hope that helps you understand my question more, sorry for being confusing at first.
@BytesNBits
@BytesNBits 2 жыл бұрын
@@ThePrintHouse Hi. I see which bit you mean. The 20 is just that the calibration crosses are drawn 20 pixels in from the edge of the screen. So when we substitute the values into the equation pixelPosition = m(TouchValue) + c we use 20 for the pixelPosition. so c = 20 - m(touchValue).
@ThePrintHouse
@ThePrintHouse 2 жыл бұрын
@@BytesNBits ok great. That is what I thought, but I just wanted to make sure. I'm modifying the code to use more equations based on variables (so everything can be easily modified) and just needed to make sure I used the right math.
@April2023-fb6pf
@April2023-fb6pf 11 ай бұрын
Can we use for another shield tft?
@BytesNBits
@BytesNBits 11 ай бұрын
Yes. You might need to check the driver chips and modify the code to suit your hardware, but the general process is the same.
@April2023-fb6pf
@April2023-fb6pf 11 ай бұрын
My tft shield with arduino uno get a white screen. Where my problem
@user-vz6fq4sn4f
@user-vz6fq4sn4f 3 жыл бұрын
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!
@BytesNBits
@BytesNBits 3 жыл бұрын
Can you get the screen working by itself without any other devices connected?
@user-vz6fq4sn4f
@user-vz6fq4sn4f 3 жыл бұрын
@@BytesNBitsThank you very much for the answer. With the demo code I ran the screen works.
@BytesNBits
@BytesNBits 2 жыл бұрын
Can you get the sensors working without the screen - just use the example sensor sketch. If everything works separately you'll need to look at your sketch that pulls it all together. Use the serial terminal to print debug messages as the code runs so you can see what it's trying to do and if it gets stuck somewhere. Try initialising the screen and displaying something, then pause for a few seconds so you can visually see if it worked before reading the sensors. It's probably something you've missed out on the code to get it all set up correctly.
@user-vz6fq4sn4f
@user-vz6fq4sn4f 2 жыл бұрын
Good Evening . I have a problem with the initialization of this screen, the sensors work without the screen. The problem is that it is not the same, my screen, with yours and I do not know what to initialize and how to use it. Do I have to initialize all the pins?
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. You're almost there! The screen works and the sensors work. The screen has a chip select pin that tells it to listen to the SPI channel. This needs to be initialised as an output and set to off (high) as soon as you power up the project. If you're using the touchscreen make sure you do the same for it's chip select pin. This stops the LCD receiving random signals that might upset it. You can then initialise your sensors and then the screen. If it doesn't work try initialising the screen but hold off doing anything with the sensors for a few seconds to see if the screen gets up and running before you access the sensors. If it then goes blank when you use the sensors you'll know there's something in the sensor code that's knocking out the screen.
@paulunsinn6670
@paulunsinn6670 Жыл бұрын
THX
@BytesNBits
@BytesNBits Жыл бұрын
No problem
@vivekrohella9400
@vivekrohella9400 2 жыл бұрын
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.
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. Have you tried running a sketch that just uses the touch function without even loading in the LCD driver? This should verify if the touch setup is working. Once you've verified that it's all OK you'll know that it's some sort of issue combining the software. I found that you need to get all the chip select signals and Reset on the LCD set up first before you try to initialise the SPI parts. There seems to be some crossover if you don't. Also check that the touch panel can run at the SPI baud rate you select. I think the LCD can run at a much higher frequency that the touch panel parts. I hope this helps.
@vivekrohella9400
@vivekrohella9400 2 жыл бұрын
@@BytesNBits Thanks for details provided. I have tested with UNO. It is working properly. Then I tried it with Mega & Due. Everything is working except touch. Pin Details in last message. Kindly note that I have used SD Card module. Both ILI9341 & SD module MIOS, MOSI & SCK are connected parallel.
@BytesNBits
@BytesNBits 2 жыл бұрын
@@vivekrohella9400 That seems strange. Have you tried with just the touch connected on the Mega and Due?
@vivekrohella9400
@vivekrohella9400 2 жыл бұрын
@@BytesNBits Tried but it's not working. Then I tried example sketch of LCDWIKI. Everything is working ok.
@BytesNBits
@BytesNBits 2 жыл бұрын
@@vivekrohella9400 Did the working example use the same touch screen library? If not I'd substitute that one into your project.
@azulfenix7
@azulfenix7 Жыл бұрын
errors in the code
@BytesNBits
@BytesNBits Жыл бұрын
I'll have to have a look and see if this is getting out of date.
@stoptheirlies
@stoptheirlies Жыл бұрын
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
@BytesNBits
@BytesNBits Жыл бұрын
Sorry you're having problems. I've had a look at the code. It's all OK apart from the website code renderer has replaced the < symbols with the html code &lt; and > with &gt;. I think this is on the older code listings. Do a find and replace and the code should compile, though do have a look in case some other characters have been replaced. I assure you I do care. This is why I post these videos. I try to answer as many comments as I can.
@atihrot755
@atihrot755 2 жыл бұрын
Dear Mr. Those codes don't work for me at all. I can't run drawing on the LCD. Can you help me?
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. Your best bet is to try each part of the project separately. Make sure you can get the LCD panel working. Then try the basic touch screen functions and then try putting it all together.
Coding Games on an ILI9341 SPI LCD and Touchscreen - Arduino
1:05:46
Bytes N Bits
Рет қаралды 12 М.
Basic animation in your SPI LCD touchscreen
41:04
Bytes N Bits
Рет қаралды 24 М.
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 6 МЛН
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,9 МЛН
Can You Find Hulk's True Love? Real vs Fake Girlfriend Challenge | Roblox 3D
00:24
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 4,7 МЛН
Arduino Touchscreen Display - Using a Resistive Touchscreen
38:51
DroneBot Workshop
Рет қаралды 413 М.
Arduino - Buttons on the TFT Touchscreen
29:10
Basement Electronics
Рет қаралды 44 М.
3.5" TFT Color TOUCH Display-DRIVER ILI9488 for NodeMcu ESP32
8:06
IR Remotes & Microcontrollers - Arduino & ESP32
1:31:50
DroneBot Workshop
Рет қаралды 219 М.
Using a 2.8in SPI LCD Touchscreen ILI9341 with an ESP32 on the new Arduino IDE 2
10:34
How to use and why to use Sprites  (TFT_espi Programing tutorial)
13:30
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 6 МЛН