Button to serial

If we want to easily track how a button acts, serial communication is the best and simplest way. All we need to do is to read the status of the button and print it to the serial connection.

Testing whether a button is working can be solved by using an LED. However, if we need to check two buttons or better understand what's happening when the button is pressed, serial communication is much safer and may even be simpler.

Getting ready

The following are the ingredients required to execute this recipe:

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

How to do it…

This recipe uses the Button with no resistor recipe's hardware implementation. Please implement the same schematic as in that recipe. We will have different code here, ...

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.