Analog pins A6 and A7 are not usable as GPIO on ATmega168/328 #2584
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On the ATmega168 and ATmega328[P], pins ADC6 and ADC7 are different from the other ADC pins: they are not part of any port, and therefore are only usable as analogue inputs, not as GPIO. It can get very confusing when you try to configure them as
INPUT_PULLUP
on the Arduino Nano, for example. I know I was, and that I’m not the only one.This is visible on the block diagram in the microcontroller datasheet (it’s identical for both the 168 and the 328.) Notice how
ADC[6 to 7]
at the bottom right bypasses any Port block:I initially just wanted to open an issue, or make a simple PR with a warning about the ATmega168 and ATmega328[P], but I got nerd sniped and ended up investigating all the boards mentioned in the docs to check which were being affected. Hopefully I didn’t make any mistakes.
Moreover, while examining the schematics of all the boards with the affected MCUs, I noticed that the schematics for the Arduino Diecimila and Arduino Duemilanove feature an ATmega8 instead of the ATmega168 mentioned on their respective pages. I’m not submitting any change regarding this in this PR.
What This PR Changes
This PR updates the Analog Input Pins page to include a generic warning about pins A6 and A7 right where it says “the analog pins may be used for GPIO,” and a caveat at the end of the page that lists the affected boards I could identify, which are:
The other boards with these MCUs don’t appear to have A6 and A7 routed to pin headers.
Moreover, it fixes the number of analogue input pins on the documentation page for the Arduino Pro Mini. It has 8 analogue inputs, 4 on the headers on the edge of the board, and 4 on holes in the interior of the board.
Contribution Guidelines