I'm creating a temperature control simulation and there is a LED used to represent the light bulb which is turned on via the toggle switch. I have successfully included state change detection and tried it on a Arduino board where the LED turns on with no problem as the Push button functions as a toggle switch.
Once I move this set of code of the push button into another board with other components included, the LED takes awhile to turn on after clicking the push button, sometimes I need to hold onto the push button around 5 seconds for it to turn on however it was working fine on it's own. It is probably due to all the other code from the other components. Is there a way to get the push button and led to work same as it did on it's own Arduino board.
The part of the code I am talking about is the //pushbutton toggle switch code, I've moved this set of code at different places within the void loop and the problem still persists.
i suggest to print millis() at various points in you code to determine how long it's taking, along with the state of the button press. make sure you print a timestamp at the very beginning and very end of loop