user55430: On an ATmega2560, can ports have some pins used for analog inputs but others as digtial i/o? Specifically, I only need to use 3-5 analog inputs but have many digital inputs. I would like to use the remaining 3-5 pins as digital outputs if possible.
Additionally, does it make a difference if the port in question is Port F vs. Port K? For Port F, the datasheet seems to imply that all 8 of the pins are analog only if the ADC is enabled:

Port F serves as analog inputs to the A/D Converter.
Port F also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used.

For Port K, however, the datasheets port description does not have the distinction:

Port K serves as analog inputs to the A/D Converter.
Port K is a 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).

It seems that this is definitely possible for the Arduino Uno/ATmega328P ADC port (except for the ADC6/7 pins for 32-pin form factors), but I can't seem to find anything confirming for the Arduino Mega/ATmega2560 or distinguishing between whether this is done on Port F or Port K

user13432: 
On an ATmega2560, can ports have some pins used for analog inputs but others as digtial i/o? 

Yes, the ADC MUX controls the selection of the pin that is connected to the converter. This is independent of the digital pin control. 
Cheers!
PS: See the Arduino core source code for further details on the ADC MUX control registers. 

55430: <p>On an ATmega2560, can ports have some pins used for analog inputs but others as digtial i/o? Specifically, I only need to use 3-5 analog inputs but have many digital inputs. I would like to use the remaining 3-5 pins as digital outputs if possible.</p>
<p>Additionally, does it make a difference if the port in question is Port F vs. Port K? For Port F, the datasheet seems to imply that all 8 of the pins are analog only if the ADC is enabled:</p>
<blockquote>
<p>Port F serves as analog inputs to the A/D Converter.</p>
<p>Port F also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used.</p>
</blockquote>
<p>For Port K, however, the datasheets port description does not have the distinction:</p>
<blockquote>
<p>Port K serves as analog inputs to the A/D Converter.</p>
<p>Port K is a 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).</p>
</blockquote>
<p>It seems that this is definitely possible for the Arduino Uno/ATmega328P ADC port (except for the ADC6/7 pins for 32-pin form factors), but I can't seem to find anything confirming for the Arduino Mega/ATmega2560 or distinguishing between whether this is done on Port F or Port K</p>
 13432: <blockquote>
  <p>On an ATmega2560, can ports have some pins used for analog inputs but others as digtial i/o? </p>
</blockquote>

<p>Yes, the ADC MUX controls the selection of the pin that is connected to the converter. This is independent of the digital pin control. </p>

<p>Cheers!</p>

<p>PS: See the Arduino core source code for further details on the ADC MUX control registers. </p>
