Will analogread(6) be able to control ADC6?

Hi Arduino experts,

I am using Atmega328. As I have run out of ports, I am forced to use ADC6 and ADC7. However, these 2 pins are not in the Arduino pin-mapping. May I ask if analogread(6) is able to access ADC6?

Thank you.

Search this forum for references to those 2 ports and you will find that other people have tried to access the ports with varying degrees of success.

Probably not.

But there is a file in the Arduino software, called "variants/eightanaloginputs/pins_arduino.h" which changes the 6 analog inputs to 8.
Perhaps that is automatically included for some boards, but I can't find which boards.

I have a Pro Mini clone, which has A0 to A7. But I have not tried A6 and A7 yet.

Or you can set the MUX register, as is done in the function for the internal temperature, Arduino Playground - InternalTemperatureSensor

The A6 and A7 can only be used as analog inputs, you can't use them as digital pins.

Erdin:
Probably not.

But there is a file in the Arduino software, called "variants/eightanaloginputs/pins_arduino.h" which changes the 6 analog inputs to 8.
Perhaps that is automatically included for some boards, but I can't find which boards.

I have a Pro Mini clone, which has A0 to A7. But I have not tried A6 and A7 yet.

If you look at the boards.txt file, you'll find a description like this:

mini328.name=Arduino Mini w/ ATmega328

mini328.upload.protocol=arduino
mini328.upload.maximum_size=28672
mini328.upload.speed=115200

mini328.bootloader.low_fuses=0xff
mini328.bootloader.high_fuses=0xd8
mini328.bootloader.extended_fuses=0x05
mini328.bootloader.path=optiboot
mini328.bootloader.file=optiboot_atmega328-Mini.hex
mini328.bootloader.unlock_bits=0x3F
mini328.bootloader.lock_bits=0x0F

mini328.build.mcu=atmega328p
mini328.build.f_cpu=16000000L
mini328.build.core=arduino
mini328.build.variant=eightanaloginputs

Check out the last line. Most boards use a build.variant of "standard".

You can always use analogRead (6) and analogRead (7), which should just work.

And no, you can't control ADC6 or 7, they are only wired to the analog multiplexer, so have no output
capability. In fact port C bit 6 can be mapped to the RESET pin if the chip is appropriated fused, and port C
bit 7 is unassigned. The standard bootloader keeps the reset pin as a reset signal so bits 6 and 7 of port
C are not used.

The analog inputs 0..5 share pins with digital port C bits 0..5, hence they can be set as digital I/O.

MarkT:
You can always use analogRead (6) and analogRead (7), which should just work.

And no, you can't control ADC6 or 7, they are only wired to the analog multiplexer, so have no output
capability. In fact port C bit 6 can be mapped to the RESET pin if the chip is appropriated fused, and port C
bit 7 is unassigned. The standard bootloader keeps the reset pin as a reset signal so bits 6 and 7 of port
C are not used.

The analog inputs 0..5 share pins with digital port C bits 0..5, hence they can be set as digital I/O.

Sorry, I am confused. Why do you first say analogRead (6) should just work and then followed with ADC6 can't be controlled? If I interpret correctly, do you mean ADC6 can be read as an analog input via analogRead(6) but cannot be used as an digital output pin?

Thank you.

ADC6 can be read as an analog input via analogRead(6) but cannot be used as an digital output pin - exactly.

CrossRoads:
ADC6 can be read as an analog input via analogRead(6) but cannot be used as an digital output pin - exactly.

Is this an Arduino restriction, or an AVR thing? Can ADC6 be set as a digital output pin in Atmel Studio?

Page 75 of the 328 datasheet says "All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports."

I'm assuming ADC6 is not considered a port?

This has already been answered above, port C bit 6 is the reset pin, port C bit 7 is
not used at all. Standard Arduinos do not configure port C bit 6 for use so that
the pin can be used as RESET.

Analog inputs 6 and 7 have nothing at all to do with port C or any other port.

Only surface mount versions of the ATmega chip bring out analog inputs 6 and 7.

MarkT:
This has already been answered above, port C bit 6 is the reset pin, port C bit 7 is
not used at all. Standard Arduinos do not configure port C bit 6 for use so that
the pin can be used as RESET.

Analog inputs 6 and 7 have nothing at all to do with port C or any other port.

Only surface mount versions of the ATmega chip bring out analog inputs 6 and 7.

So on the AtMega328 smd version, ADC6 is an analog input only. It cannot be configured under any circumstances to be either a digital or analog output, correct?

Correct - analog input only.
Here's their complete description from the datasheet:

ADC7:6 (TQFP and QFN/MLF Package Only)
In the TQFP and QFN/MLF package, ADC7:6 serve as analog inputs to the A/D converter. These pins are powered from the analog supply and serve as 10-bit ADC channels.

Note that ADC pins ADC7 and ADC6 do not have digital input buffers, and therefore do not require Digital Input Disable bits.

So the two extra SMD pins can be read with AnalogRead(6) for ADC6 and AnalogRead(7) for ADC7? Sounds great - will give it a shot!

Make sure you review boards.txt and select a board type that uses "eightanaloginputs"

Such as:
nano328.build.variant=eightanaloginputs