I think is a "too short" loop. Using a double while to catch an input causes that both IF can be valid thousand of times until you release the pushbutton. A suggest you to manage it on the release of button, that means you trigger the push of button and...