1,000 buttons to 1 pin
One button, one pin—that is the way things are usually done on Arduino boards. But it is so limiting. There are some tricks that let you connect more than one button to a pin. Actually, it is even possible to connect 1,000 buttons to just 1 pin. We will explore this possibility in this recipe.
Getting ready
The following are the ingredients required for this recipe:
An Arduino board connected to a computer via USB
A breadboard and jumper wires
Three buttons
Four resistors of equal value: 1K ohm works well
How to do it…
We implement a simple configuration using only three buttons on the same pin. Here are the steps:
Connect the Arduino GND to a long strip on the breadboard. Also connect the Arduino 5V to a long strip.
Connect one of the resistors from the GND strip to an analog pin—here, pin A0—on the Arduino.
Connect three resistors in series starting at the 5V strip.
At each junction of two resistors, connect one button. Also connect the third button at the end of the resistor...