6 min read
Why Is My Arduino Button Not Working?
A button that seems dead is usually a wiring or configuration issue. Work through the five checks below in order and the fault will show up quickly.

At a glance
- 6 sections
- 4 answered questions
- 3 linked pages
- No installation needed
1. The input is floating
If the pin is configured as plain INPUT and nothing ties it to a defined level, the reading wanders. The button may appear to work only when you touch the wire. Enable the internal pull-up with pinMode(pin, INPUT_PULLUP) and wire the button between that pin and ground.
A floating input is the most common reason a button appears random rather than broken. It is fixed in one line of code and one wire.
2. Pull-up logic is inverted
With a pull-up, the pin reads HIGH when the button is released and LOW when it is pressed. A sketch that waits for HIGH will therefore react on release, which feels like the button is not working. Compare against LOW, or invert the reading once and use a clear variable name.
Print the raw value to the serial monitor and press the button. If the number changes in the opposite direction to your expectation, this is the cause.
3. The button straddles the trench incorrectly
Rows of holes on each side of the central trench are connected horizontally, but the trench separates them. If both legs of the button sit in the same connected row, the switch is shorted out. If both legs sit in different rows but you wired only one leg, nothing happens.
Place the button across the trench, then confirm that each jumper lands in the row that holds the leg you intended. A continuity test with a meter removes all doubt.
4. Contact bounce fools the code
A press can generate several rapid transitions as the contacts meet. A counter will jump by more than one, and a toggle may flip twice and appear to do nothing. Ignore changes for 20 to 50 milliseconds after the first one, using millis() instead of delay so the rest of the program keeps running.
Bounce is not a hardware failure. It is a normal property of mechanical switches and belongs in the software.
5. Wrong pin number or missing pin mode
digitalRead only works after pinMode has set the pin as an input. If the number in the code differs from the pin you wired, the reading never changes. Analog pins can be used as digital inputs, but you must refer to them correctly in the sketch.
Write the pin number on a scrap of paper and hold it next to the board while you compare. It is faster than tracing the same wire twice.
A five-minute debug routine
Open the serial monitor and print the raw reading ten times a second. With the button released you should see a steady HIGH; while pressed, a steady LOW. If the value wanders, fix the pull-up. If it never changes, check the two wires and the trench. If it changes too often, add debounce.
Only move on to the LED or the rest of the program once the raw reading is clean. Debugging a button through an output adds a second variable to an already unclear situation.
Frequently asked questions
Why does my button work only when I touch it?
The input is floating. Add INPUT_PULLUP and connect the button to ground.
Why does my code react on release?
A pull-up input reads HIGH when released and LOW when pressed. Invert the logic.
How much debounce do I need?
20 to 50 milliseconds covers most mechanical switches. Use millis() so the rest of the loop is not blocked.
Can I use an analog pin for a button?
Yes. Analog pins work as digital inputs with pinMode and digitalRead, including INPUT_PULLUP.
Related pages
Keep learning
Continue with a hands-on project, a browser simulator or a free account.
- → Connect a button without a resistor
- → Button and LED project
- → Circuit simulator
- → Save your circuit — save progress across lessons