0
\$\begingroup\$

Something that is confusing me on the Arduino is the Analog Inputs. Can they be used as normal I/O Digital or only I Analog?

asked May 17, 2012 at 14:08
\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

On most microcontrollers that have special functions for their I/O, like analog in, but also PWM, UART or I2C, these pins can also be used as General I/O (digital). The Atmel AVR is no exception. You'll have to check the datasheet to see which register(s) enable/disable the special functions.

enter image description here

This is a detail of the pinout of the ATMega328, which is apparently used in the Arduino Uno (thanks bjthom). You can see that pin24, which is used as ADC1 input, also is used as port PC1 (bit 1 of port C).

answered May 17, 2012 at 14:13
\$\endgroup\$
1
  • \$\begingroup\$ It may be worth noting that the Arduino Uno R3 (the most recent board) uses the ATmega328. \$\endgroup\$ Commented May 17, 2012 at 14:54
2
\$\begingroup\$

The simple answer is yes, they can be used as digital I/O as well. Within the framework of the Arduino core libraries, I'm pretty sure you can just treat them as digital 14 through digital 19. So to set "A0" as an output and drive it low you would do:

pinMode(14, OUTPUT);
digitalWrite(14, LOW);
answered May 17, 2012 at 14:59
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Analog pins can also be referred to as Ax in sketches, where x is the input number. \$\endgroup\$ Commented May 17, 2012 at 15:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.