More digital pins

There are times when we need more digital pins on the Arduino without any other external components. An Arduino Uno has 14 digital pins, from 0 to 14, right? Wrong! It actually has 20. The analog in ports can at all times be used as digital ports, and they have all the functionality of normal digital ports.

Tip

A word of caution: pins 0 and 1 are the UART ports used for programming need to take extra care about what we connect there, because when we are programming the board, those pins will switch from HIGH to LOW thousands of times.

Getting ready

Just one ingredient is needed for this recipe—an Arduino Board connected to a computer via USB.

How to do it…

The following code shows how to use pins A0 and A1 as normal digital pins:

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.