(Arduino UNO) Random Button inputs due to change in code
With the current configuration, your inputs are floating when the buttons aren't pressed. Thus, if no button is pressed, the input could be anything. You have no control. A better solution would be as follows:







simulate this circuit &ndash; Schematic created using CircuitLab

Now, with no button pressed, the input is pulled up to 5V. With a button press, the input is pulled down to ground.