Touchscreen Issues

So I’m working on an aeroponics project where I want to display certain sensor readouts (temperature and humidity from a DHT11 amongest others) onto a screen but the problem is that when I started using the touchscreen feature the buttons would not respond. I’ve programmed a home screen which serves as a menu with two buttons which would take the user to the corresponding pages. I have ruled out hardware being a issue because all the examples ran smoothly on the touchscreen and I found out that if I comment out the sensor loops the touchscreen functions work flawlessly with no lags. I’m not really sure why this is the case and I would really appreciate it if anyone can take a look at it ans see what I did wrong! I have uploaded the code below with a picture of the homescreen.

The microcontroller that I’m testing it on is the MEGA2560 and the link to the touchscreen I purchased is below:

April_30th.ino (11.6 KB)

Your sensor reading code e.g. pressuresensor() is littered with delay() statements which will almost certainly have an impact on the touch screen reading code.

6v6gt:
Your sensor reading code e.g. pressuresensor() is littered with delay() statements which will almost certainly have an impact on the touch screen reading code.

Hey thanks for the reply. Is there a solution to this? I’m going down the sensors in order and didn’t even get to the pressure sensor yet!

The solution is to eliminate the delay() statements using, say, the same technique as in the now famous "blink without delay" example in the Arduino development software (IDE). During the time your code is "stuck" in a delay(), nothing else can happen. That includes attempts to react to a button press.