user11602: I recently created a circuit to read the value from two sets of buttons using only two analog pins. It involves setting one pin HIGH and reading the input on the other pin and then swapping. With both pins set to OUTPUT I can still read in values with analogRead() without having to keep switching pin modes.
My question is why is that the case? What is the point of setting a pin to INPUT if OUTPUT can still read in values? Are there any disadvantages of doing so?

user4143: The reason for this is because analogRead() has absolutely nothing to do with what mode the pin is in.  That mode only has any meaning in the scope of digital operations - i.e., when using digitalRead() and digitalWrite().  When using analogRead() the Arduino code switches the pin into analog mode first and then reads from it.

user10794: 
My question is why is that the case? What is the point of setting a pin to INPUT if OUTPUT can still read in values? Are there any disadvantages of doing so?

If you do a digitalRead you can read the current latched state of an output pin (it doesn't change it to input). In other words, you read what was last written to it.
If you do a digitalWrite of HIGH to an input pin it sets the internal pull-up. If you write LOW it disables the internal pull-up. If it switched it to output for you, you wouldn't be able to enable or disable the pull-up. (Note: this applies to older versions of the IDE, newer ones have a pinMode setting of INPUT_PULLUP).

What is the point of setting a pin to INPUT if OUTPUT can still read in values? 

That certainly won't work with digitalRead because you are writing a value to the pin in OUTPUT mode, so you will merely read back what you are writing. In other words, you have activated the driver transistors, which will override whatever value you are trying to read.

11602: <p>I recently created a circuit to read the value from two sets of buttons using only two analog pins. It involves setting one pin <code>HIGH</code> and reading the input on the other pin and then swapping. With both pins set to <code>OUTPUT</code> I can still read in values with <code>analogRead()</code> without having to keep switching pin modes.</p>

<p>My question is why is that the case? What is the point of setting a pin to <code>INPUT</code> if <code>OUTPUT</code> can still read in values? Are there any disadvantages of doing so?</p>
 4143: <p>The reason for this is because <code>analogRead()</code> has absolutely nothing to do with what mode the pin is in.  That mode only has any meaning in the scope of <em>digital</em> operations - i.e., when using <code>digitalRead()</code> and <code>digitalWrite()</code>.  When using <code>analogRead()</code> the Arduino code switches the pin into analog mode first and then reads from it.</p>
 10794: <blockquote>
  <p>My question is why is that the case? What is the point of setting a pin to INPUT if OUTPUT can still read in values? Are there any disadvantages of doing so?</p>
</blockquote>

<p>If you do a <code>digitalRead</code> you can read the current latched state of an <strong>output</strong> pin (it doesn't change it to input). In other words, you read what was last written to it.</p>

<p>If you do a <code>digitalWrite</code> of HIGH to an <strong>input</strong> pin it sets the internal pull-up. If you write LOW it disables the internal pull-up. If it switched it to output for you, you wouldn't be able to enable or disable the pull-up. (Note: this applies to older versions of the IDE, newer ones have a pinMode setting of INPUT_PULLUP).</p>

<blockquote>
  <p>What is the point of setting a pin to INPUT if OUTPUT can still read in values? </p>
</blockquote>

<p>That certainly won't work with <code>digitalRead</code> because you are writing a value to the pin in OUTPUT mode, so you will merely read back what you are writing. In other words, you have activated the driver transistors, which will override whatever value you are trying to read.</p>
