I am working on smart home project, where I am using touch sensor as a push button, actually I make my touch sensor as a push button just because I can't turn off my touch button from coding, for better understanding I will give you some example:
I am checking button state value from both sides. I.e. server side and by physical pressing, so when I press button physically it works fine but when i changes button status from server side then due to my button state is high or low, it instantly changing my value to previous one, so i am unable to change button state from server side.
So that's why i used my touch sensor as a push button so when user click on it, it change some variable value and on the bases of that value I can handle state of button from both side, but problem is i am checking lot of data continuosly so my loop is slowing
I am checking button press by following method
If(digitalRead(button = HIGH)) {
StateOfButton = !StateOfButton
So in my side, i need to instantly call this method whenever user clicks touch sensor, but in my code it's taking 500ms-800ms, I tried to print when loop recall, and loop print by delay of 1 sec 4 times and then recalling loop very fast more than 20+ in second, so any one have any suggestions what can i do