Button with no resistor

It is simple to connect a button to the Arduino. You need the button, some wires, and a resistor. But what if we no longer need the resistor and want to still be able to use the button with no false readings?

The resistor is mandatory for proper operation of a button, and everybody will insist on using it. However, there is a little secret embedded in each Arduino pin. Each pin already has a pull-up resistor that we can enable with just one small change in our code.

Getting ready

For this recipe, you will need just two components:

  • An Arduino board connected to a computer via USB
  • A push button

How to do it…

There is just one simple step in this recipe:

  1. Connect the Arduino GND to a terminal on the button and connect the chosen digital ...

Get Arduino Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.