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

Connecting a button


One of the basic interactions you can have with the Arduino is pushing a button, which causes another action. Here, we will see how to connect and use a button.

To keep the example simple, we will connect a button to the Arduino, and whenever we press and hold it, the internal Arduino LED will light up. But first, we need to talk a little about buttons. There are a few common configurations found in everyday electronics. We can categorize buttons/switches based on three main characteristics:

  • Momentary and maintained buttons

  • Open or closed buttons

  • Poles and throws

Momentary buttons are active as long as they are pressed, while maintained buttons keep the state we let them in. Keyboards have momentary buttons while the typical light switch is a maintained button.

Momentary buttons can either be opened or closed. This reflects the connection state when not pressed. A closed momentary switch will conduct current while not pressed and interrupt the current when pressed. An opened...