Arduino calibrate

hi guys im beginner at ardunio im having a problem
this exactly what im working on

but when im ordring dish 1 its order dish 5
and when im ordring dish 2 its ordring other thing .. its messy
what should i do plz help this university project
and the code is here

The lines like this are what associates a messages with the area of the screen touched. If the numbers are wrong you will get the wrong button associated with each area of the screen.

if (p.x > 30 && p.x < 70 && p.y > 130 && p.y < 230 && p.z > MINPRESSURE && p.z < MAXPRESSURE) {

The touch areas should relate to where the button was drawn:

  tft.fillRoundRect(10, 30, 100, 40, 8, GOLD);
  tft.drawRoundRect(10, 30, 100, 40, 8, WHITE);  //Dish1

  tft.fillRoundRect(10, 80, 100, 40, 8, GOLD);
  tft.drawRoundRect(10, 80, 100, 40, 8, WHITE);  //Dish2

  tft.fillRoundRect(10, 130, 100, 40, 8, GOLD);   //Dish3
  tft.drawRoundRect(10, 130, 100, 40, 8, WHITE);
1 Like

Write the code yourself, as expected for a university project.

1 Like

+1.

You must come to enough of an understanding of how the hardware works, and how this program works, to be able to find and fix the problems you are having.

Write a small program that does nothing but serial print coordinates as you touch the screen.

As has been suggested, those numbers aren't working correctly with the way the code is interpreting them.

Just you and the touchscreen, until you are sure the corners are where the should be and the axes are not mirror, flipped or rotated.

a7

2 Likes

It looks like SOMETHING is swapped. The "Dish1" button is drawn at (10, 30, 100, 40) and I assume that's X, Y, Width, Height. That would put the button between 10 and 110 in X and 30 and 70 in Y but the code for detecting a press on "Dish1" is using:
p.x > 30 && p.x < 70
p.y > 130 && p.y < 230
That indicates that the X and Y axis are swapped between the graphics and the touchscreen and that one axis (X on graphics, Y on the touchscreen) is reversed.

1 Like

this is my first time using arduino :frowning:

Will your instructors approve of you copying someone else's code and making a botch of it?

It is a really good idea to learn Arduino basics and the programming language, before starting on a "university project".

bro how should i know coding if this is my first time and my instructors wouldnt help me just ignoring me all the time

Like everyone else, start with the simple examples in the Arduino IDE, and learn to read switches, sensors, print on the screen, etc.

There are plenty of on line Arduino tutorials, and for the C/C++ programming language.

If the instructors ignore you, show them you can learn by yourself!

im tying man ive learned some stuff so this is why im asking for help

You have a long way to go, so keep at it!

Yes sir they are the same but i still have this problem
and thx for help

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.