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 ...

Get Arduino Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.