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

Поділитися
Вставка
  • Опубліковано 6 січ 2025

КОМЕНТАРІ • 81

  • @71Elizabeth_Bergman
    @71Elizabeth_Bergman Місяць тому

    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  Місяць тому +1

      Good to hear you're getting it working.

  • @danielewusi-essel219
    @danielewusi-essel219 3 роки тому +2

    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!

  • @TechFixDIY
    @TechFixDIY 2 місяці тому

    I enjoy your starting animation more than the video 😁

    • @BytesNBits
      @BytesNBits  2 місяці тому

      I did make some videos on coding that game if you fancy having a go. Look for the Space Commander series.

  • @jumbo999614
    @jumbo999614 3 роки тому +1

    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 роки тому +1

      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
      ua-cam.com/video/qNgTjCcv9vM/v-deo.html

  • @ПетърЧуклев-м4ч

    Благодарим ви!

  • @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.

  • @gnather
    @gnather 2 роки тому +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.

  • @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.

  • @padesmo
    @padesmo 3 місяці тому

    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  3 місяці тому

      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 3 місяці тому

      @@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

  • @halalbach1855
    @halalbach1855 3 роки тому +1

    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 < 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 " > ".
    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 < looks like an html thing.

    • @johnvine5731
      @johnvine5731 2 роки тому +1

      It might be a browser problem.
      The browser cannot display the 'greater than' and 'less than symbols' .
      So, instead of < and >, the browser displays < and >.
      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 роки тому +1

    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 .

  • @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.

  • @coby1kenobii
    @coby1kenobii 4 роки тому +1

    love the animations!

  • @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.

  • @YasirChoudhary-bp6uh
    @YasirChoudhary-bp6uh Місяць тому

    Bro I made esp32 marauder but i face screen rotating problem (I used 2.4 tft display ) plz help me

    • @BytesNBits
      @BytesNBits  Місяць тому

      In the Adafuit library there are commands to set the screen rotations. You just need to play around with those to get it the right way round. Make sure you get the touchscreen to match!

  • @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 Рік тому

      @@larrybud I had to put the project aside. Hoping to get back to it at some point.

  • @PhamhongDung68
    @PhamhongDung68 10 днів тому

    How wire ts_sck pin, ts_din pin,ts_do pin and ts_irq pin

    • @BytesNBits
      @BytesNBits  10 днів тому

      the ts_sck will connect to the spi clock signal. ts_din is probably MOSI. ts_do is probably MISO. ts_irq is likely not needed so leave it disconnected. There should also be a chip select pin.

  • @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 :)

  • @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.

  • @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 роки тому +1

      @@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.

  • @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 < and > codes with < and > it should work. I'll try and update the code listing over the next few days.

  • @April2023-fb6pf
    @April2023-fb6pf Рік тому

    Can we use for another shield tft?

    • @BytesNBits
      @BytesNBits  Рік тому

      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 Рік тому

      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  3 роки тому

      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 3 роки тому

      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  3 роки тому

      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.

  • @vivekrohella9400
    @vivekrohella9400 3 роки тому

    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  3 роки тому

      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 3 роки тому

      @@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  3 роки тому

      @@vivekrohella9400 That seems strange. Have you tried with just the touch connected on the Mega and Due?

    • @vivekrohella9400
      @vivekrohella9400 3 роки тому

      @@BytesNBits Tried but it's not working. Then I tried example sketch of LCDWIKI. Everything is working ok.

    • @BytesNBits
      @BytesNBits  3 роки тому +1

      @@vivekrohella9400 Did the working example use the same touch screen library? If not I'd substitute that one into your project.

  • @rompipelotas
    @rompipelotas Рік тому

    THANKS A LOT !!!!!!

  • @paulunsinn6670
    @paulunsinn6670 Рік тому

    THX

  • @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 < and > with >. 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.