Skip to content

Analog pins A6 and A7 are not usable as GPIO on ATmega168/328 #2584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions content/learn/02.microcontrollers/02.analog-input/analog-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A description of the analog input pins on an Arduino chip (ATmega8, ATmega168, A

The ATmega controllers used for the Arduino contain an onboard 6 channel (8 channels on the Mini and Nano, 16 on the Mega) analog-to-digital (A/D) converter. The converter has 10 bit resolution, returning integers from 0 to 1023. While the main function of the analog pins for most Arduino users is to read analog sensors, the analog pins also have all the functionality of general purpose input/output (GPIO) pins (the same as digital pins 0 - 13).

Consequently, if a user needs more general purpose input output pins, and all the analog pins are not in use, the analog pins may be used for GPIO.
Consequently, if a user needs more general purpose input output pins, and all the analog pins are not in use, the analog pins may be used for GPIO (with the exception of analog pins A6 and A7 on boards that use the ATmega168 and ATmega328P, which are purely analog).

## Pin mapping

Expand All @@ -37,4 +37,12 @@ Be aware however that turning on a pull-up will affect the values reported by an
The analogRead command will not work correctly if a pin has been previously set to an output, so if this is the case, set it back to an input before using analogRead. Similarly if the pin has been set to HIGH as an output, the pull-up resistor will be set, when switched back to an input.

The ATmega datasheet also cautions against switching analog pins in close temporal proximity to making A/D readings (analogRead) on other analog pins. This can cause electrical noise and introduce jitter in the analog system.
It may be desirable, after manipulating analog pins (in digital mode), to add a short delay before using analogRead() to read other analog pins.
It may be desirable, after manipulating analog pins (in digital mode), to add a short delay before using analogRead() to read other analog pins.

As previously mentioned, analog pins A6 and A7 on the ATmega168 and ATmega328P are purely analog, and cannot be used for GPIO. This affects the following models:

* Arduino Nano
* Arduino Mini 05 (with ATmega168, Arduino Mini 03 and 04 use an ATmega8 and are not affected)
* Arduino Pro Mini
* Arduino BT (analog inputs A6 and A7 are available on JP1)
* Arduino Fio
6 changes: 3 additions & 3 deletions content/retired/01.boards/arduino-pro-mini/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ source: "https://store.arduino.cc/arduino-pro-mini"

The **Arduino Pro Mini** is a microcontroller board based on the [ATmega328P](http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf).

It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, an on-board resonator, a reset button, and holes for mounting pin headers. A six pin header can be connected to an FTDI cable or Sparkfun breakout board to provide USB power and communication to the board.
It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 8 analog inputs, an on-board resonator, a reset button, and holes for mounting pin headers. A six pin header can be connected to an FTDI cable or Sparkfun breakout board to provide USB power and communication to the board.
The Arduino Pro Mini is intended for semi-permanent installation in objects or exhibitions. The board comes without pre-mounted headers, allowing the use of various types of connectors or direct soldering of wires. The pin layout is compatible with the Arduino Mini.

There are two version of the Pro Mini. One runs at 3.3V and 8 MHz, the other at 5V and 16 MHz.
Expand Down Expand Up @@ -63,7 +63,7 @@ Each of the 14 digital pins on the Pro Mini can be used as an input or output, u
* **SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).** These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.
* **LED: 13.** There is a built-in LED connected to digital pin 13\. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

The Pro Mini has 8 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). Four of them are on the headers on the edge of the board; two (inputs 4 and 5) on holes in the interior of the board. The analog inputs measure from ground to VCC. Additionally, some pins have specialized functionality:
The Pro Mini has 8 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). Four of them (inputs 0 through 3) are on the headers on the edge of the board, and two (inputs 4 through 7) on holes in the interior of the board. The analog inputs measure from ground to VCC. Additionally, some pins have specialized functionality:

* **I2C: A4 (SDA) and A5 (SCL).** Support I2C (TWI) communication using the [Wire library](https://www.arduino.cc/reference/en/language/functions/communication/wire/).

Expand Down Expand Up @@ -109,7 +109,7 @@ The dimensions of the Pro Mini PCB are approximately 0.7" x 1.3".
| UART | 1 |
| SPI | 1 |
| I2C | 1 |
| Analog Input Pins | 6 |
| Analog Input Pins | 8 |
| External Interrupts | 2 |
| DC Current per I/O Pin | 40 mA |
| Flash Memory | 32KB of which 2 KB used by bootloader \* |
Expand Down