Button does not work

The button doesn't work as expected. I used the digitalRead() function to read the state of the button, but the button state is not changed as expected when press and release button. I press the button once, but Arduino code detects several presses. Why?

Answer

Beginners usually get trouble when getting started with a button, pushbutton, switch using digitalRead() function.

To avoid this, beginners SHOULD pay attention to the following issues:

1. Floating input problem:

2. Chattering phenomenon

It should be considered in only some application that needs to detect exactly number of the pressing.

Arduino chattering phenomenon

Buy Arduino and Button

1 × Arduino UNO Buy on Amazon
1 × USB 2.0 cable type A/B Buy on Amazon
1 × Button Buy on Amazon
1 × Breadboard Buy on Amazon
1 × Jumper Wires Buy on Amazon
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.

The Best Arduino Starter Kit

※ OUR MESSAGES