Button triggers by itself, or works backwards
- Push button
Why it happens
- No pull-up or pull-down resistor.
- With
INPUT_PULLUP, pressed reads LOW. - The button is turned 90°, so two joined legs are used.
How to fix it
- Use
pinMode(pin, INPUT_PULLUP);and wire the button between the pin and GND. - Then pressed is
LOW. - Use two legs that are diagonal to each other.
- For one press counted many times, add
delay(30);after it changes.
It worked if: The Serial Monitor shows 1 released and 0 pressed, steady.
Tutorials where it can happen
From how the part works. Explained from how the part works; not tried on a real circuit for this page.
Didn't help? Search another error or ask us.

