digital pins not reading input properly

So I'm trying to wire a few different push buttons into the arduino and I got two working but I'm having some difficulty with the third. I checked that the button is wired correctly with an led and it worked fine. I also wired the same pin to one of the push buttons that is already working and it worked fine. But the second I pull the wire out of the breadboard to move it to the other push button, it started saying that it was pressed all the time. The only way I could get it to stop was by wiring it back to one of the buttons that was working.

I have even tried pulling the wire out of the pin so it was not connected to anything at all but it still read as pressed.

Well, since we have no idea how you actually wiring these buttons, it is rather difficult to tell, but the buttons should each be wired from a pin to ground and you should be setting the pinMode of each to INPUT_PULLUP as per the instructions.

If the input is connected to nothing and without the pull-ups, it will generate random logic levels as it detects nearby electrical fields.

Never ever rewire a circuit that is powered up. It is one of the best ways to destroy an Arduino or in fact any electronics.

Never ever rewire a circuit that is powered up.

Now where's the fun in that?

Do you not realise how innate gambling is? :roll_eyes:

My problem was that I did not use INPUT_PULLUP, I just used INPUT. It is working now. However, pins 0 and 1 worked with just INPUT which is why I only got two pushbuttons working. The rest of the pins needed INPUT_PULLUP.

However, pins 0 and 1 worked with just INPUT

That is because they are pulled up by the serial / USB converter.

Ok, Thank You.

So the essential lesson here is - do not use pins 0 and 1 unless you have allocated all other pins (including A0 to A5) and do not wish to use the serial interface.