I'm attempting to use the pin labeled 'ADC7' from the Atmega328p TQFP package. The Atmega documentation suggests that can be used either as an analog or digital I/O point. I'm trying to configure it as a digital output.

Referencing the documentation (and specifically arduino_pins.h), I determined the associated pin number was 21. Thus I called pinMode(21, OUTPUT). However, this pin does not appear to be working with my SPI device. I previously tested that the device worked, but I made a last second change of pin and am now using ADC7.

So my question, is there an additional step required to configure this pin as a digital output? I noticed that this pin doesn't exist on the DIP Atmega328p (used on the Arduino Uno), so I'm not sure if I have to add another line of code somewhere.

Any ideas?


  • @EdgarBonet PORTC7 doesn't exist in the datasheet. PORTC6 does, but that one is connected to the reset pin and not ADC6.
    – Gerben
    Jan 17, 2017 at 18:58
  • @Gerben: Oops, you are right, I wrongly extrapolated. I'll delete my misleading comment. Jan 17, 2017 at 19:12

5 Answers 5


Those are analog pins only. They can't be used as outputs or digital inputs.

  • 1
    I'm somewhat confused then. Is there a mistake in the datasheet then? It states it can be used either as an analog or digital I/O point in the pin out. atmel.com/Images/…
    – Izzo
    Jan 17, 2017 at 20:13
  • Any analog pin on Arduino can be use ad a digital pin and I did it many times. And the AVR datasheet say that explicitly too. The only problem with Ardunino libraries/approach is, that they do not declare constants named as digital pins for pins, which can be also analog (probabelly to not "confuse users with choises"). for (int i=0;i<20;i++){pinMode(i, OUTPUT);digitalWrite(i,HIGH);delay(30);digitalWrite(i,LOW);}; works just fine and as expected (if you add LEDs+resistors to all "digital" and "analog" pins on Arduino). 1-13 are "digital", 14-19 are those "analog".
    – gilhad
    Jan 17, 2017 at 22:10
  • 1
    @gilhad, have you specifically tested A6 and A7, which the question is about? Note that Arduino #19 is A5, not A6 or A7. Don't downvote Gerben's answer on flimsy grounds. Jan 17, 2017 at 22:43
  • 1
    @gilhad ADC6 and ADC7 are only analog pins. The other analog pins also share with digital functions - ADC6 and ADC7 do not. You can see that in the table 6-1 of the datasheet - also they are only available on the TQFP-32 which the Pro Mini uses.
    – Majenko
    Jan 17, 2017 at 23:04
  • 2
    @jwpat7 : My bad, I was wrong. I mistook them with A4+A5 (as my example shows) and fast check with datasheet fig. 5-3, fig.5-4 shows them as digital/analog (also there is 28.9.8 Digital Input Disable Register, that allows to diable digital input buffer on them to save power and Table 32-2 DC characteristic, which adds them to counts for maximal source/sink sums). But I tested it on MiniPro and they are NOT outputs. Also Arduinos digitalRead() does not work with them, regardless INPUT or INPUT_PULLUP mode is selected there.
    – gilhad
    Jan 18, 2017 at 0:16

This may be a little left field, but I use the ADC6 and ADC7 inputs to detect switches. I just don't use the digitalRead() function, but instead use analogRead() function. Using a resistor network and switches and some decoder software code in our sketch, we can use a single input pin to interface with many more switches. The switches can only be on one at a time, but in many instances, this would be OK.


Gerben's answer probably is correct, but there are some interesting discrepancies in Atmel datasheets for various models of the ATmega168 and ATmega328, as outlined below.

Some Atmel datasheets refer to ADC6 and ADC7 as PE2 and PE3, while others just refer to them as ADC6 and ADC7.

Regarding port E, the 2014 ATmega168PA and 2015 ATmega168 datasheets say nothing, don't list any of PE0 to PE3, and don't specify port membership for ADC6 and ADC7. They show pins 3 and 6 on the LQFP as Gnd and Vcc, vs PE0 and PE1 as in the ATmega168PB sheet.

Regarding port E, the 2015 ATmega168PB datasheet says:

Table 15-12.  Port E Pins Alternate Functions
     Port Pin       Alternate Function
       PE3          ADC7 (ADC Input Channel 7)
       PE2          ADC6 (ADC Input Channel 6)
       PE1          NONE
       PE0          ACO (AC Output Channel 0)

Regarding port E, the 2016 ATmega168PB datasheet, Atmel-42176G-ATmega48PB/88PB/168PB_Datasheet_Complete-03/2016, says the following and also lists several Alternate Functions while referring to Timer/Counters 3 and 4 (although there seem to be no registers in the register summary relevant to such Timer/Counters):

"Port E is an 4-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port E output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port E pins that are externally pulled low will source current if the pull-up resistors are activated. The Port E pins are tri-stated when a reset condition becomes active, even if the clock is not running."

Table 19-12.  Port E Pins Alternate Functions
 Port Pin            Alternate Function
 PE3                 ADC7 (ADC Input Channel 7)
                     T3 (Timer/Counter 3 External Counter Input) & PCINT27
 PE2                 ADC6 (ADC Input Channel 6)
                     ICP3 (Timer/Counter3 Input Capture Input)
                     SS1 (SPI1 Bus Master Slave select) & PCINT26
 PE1                 T4 (Timer/Counter 4 External Counter Input)
                     SCL1 (2-wire Serial1 Bus Clock Line) & PCINT25
 PE0                 ACO (AC Output Channel 0)
                     ICP4 (Timer/Counter4 Input Capture Input)
                     SDA1 (2-wire Serial1 Bus Data Input/Output Line) & PCINT24
  • Interesting. Maybe the successor, namely the ATMega328PB, datasheet can shed some more light.
    – Gerben
    Jan 17, 2017 at 20:26
  • That's interesting, but it should be noted that the ATmega328PB has significantly more peripherals than the 328P. Now, @Teague could try something like *(volatile uint8_t *)0x2d = 0x0c; with external pullups on ADC6 and ADC7. If those pins go low, that would reveal an undocumented port E. But beware that Atmel advices against poking unassigned I/O addresses. Jan 18, 2017 at 9:42

According to everything you can find in the datasheet about ADC6 and ADC7 they are analog only pins.

The pinout for the TQFP-32 as used on the Pro Mini shows those two pins as only having the analog functions:

enter image description here

I suspect the color coding of the pins may be wrong - they should be solid green. They have no port names on the pins, purely the ADCx designation.

The block diagram for the chip shows the ADC6/7 pins being separate from a port:

enter image description here

As you can see the other 6 pins are referred to by the digital port they share, but ADC6 and 7 are known purely as ADC6 and ADC7.

The pin function table, 6-1, shows ADC6 and ADC7 as the only functions on those pins. No digital port names, nothing - just purely analog input.

So in summary, for the ATMega328P chip used in the Arduino Pro Mini you cannot use those two pins for digital at all, only for analog input.

  • 1
    Fffffff. Welp, better get some new boards printed. Thanks for the response.
    – Izzo
    Jan 17, 2017 at 23:39

I appreciate this is an old question but those pins are subtly different on the ATMEGA328PB compared to the ATMEGA328P which I discovered recently. See the Microchip app note AT15007, page 3.

Microchip AT15007 app note

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.