I have a button lag on Mega. I have several sensors (almost all analog) which i power with external power supply 12V/3A 36W. My sensors on Mega is working ok. Mega output values are ok. But button....
I have a button which acts as a switch and is connected with a relay. Button code is working except sometimes i have to keep pressure for a while.
Code for sensors is straight but there are almost 10 of them. And everything is happening in a void loop(). After a while i noticed that i have to "hunt" the time when code with reading sensors is finished and then press button.
Question is: What to do so Mega can doing loops with button code some sort of separate way of code for sensors? So it doesn't depend on time it need to finish readings? It acts some sort of i press the button but Mega isn't still get to that part of the code so it can not see it. If i press the button right it finish readings it is ok.