Cleans up the loop logic, as well as fixes the bug of missing button presses due to using the delay function.
Usage of the delay function can cause a miss in detecting a button press. To avoid this you can utilize a time based loop delay continuously listening for the button press while locking the thread into this listening loop for a specified period of time. I've also adjusted the flat if, if else, else statements into nested ifs to save time on duplicate comparisons.
Cleans up the loop logic, as well as fixes the bug of missing button presses due to using the delay function.
Usage of the delay function can cause a miss in detecting a button press. To avoid this you can utilize a time based loop delay continuously listening for the button press while locking the thread into this listening loop for a specified period of time. I've also adjusted the flat if, if else, else statements into nested ifs to save time on duplicate comparisons.