Book Image

Arduino Development Cookbook

By : Cornel M Amariei
Book Image

Arduino Development Cookbook

By: Cornel M Amariei

Overview of this book

Table of Contents (16 chapters)
Arduino Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Connect the Arduino GND to a long strip on the breadboard. Also connect the Arduino 5V to a long strip.

  2. Connect one of the resistors from the GND strip to an analog pin—here, pin A0—on the Arduino.

  3. Connect three resistors in series starting at the 5V strip.

  4. At each junction of two resistors, connect one button. Also connect the third button at the end of the resistor...