Internal pull-up confusion...

What is the difference between

pinMode(pin, INPUT);
digitalWrite(pin, HIGH);

—and—

pinMode(pin, INPUT_PULLUP);

?

As far as I can tell they are the same. I use pinMode( X. INPUT_PULLUP); because it is more clear what I,m doing.

Older versions of the IDE did not have the INPUT_PULLUP method.

It should be noted that when INPUT_PULLUP was added, there was also a change to INPUT.

After INPUT_PULLUP was implemented, pinMode(INPUT) now turns off the internal pull-up. Previous version of the core, left the data register alone, which either enabled or disabled the pull-up depending on its state.

If an pin is set to INPUT_PULLUP and then reconfigured to OUTPUT is the pullup still connected?

groundfungus:
If an pin is set to INPUT_PULLUP and then reconfigured to OUTPUT is the pullup still connected?

Looking at the code for pinMode() when configuring for OUTPUT, only the direction (mode) register is changed. So if the pull-up is enabled, when you call pinMode() the output should be a high.

The datasheet for the ATmega328 says that you should call an intermediate state, hmm. (Section 14.2.3)

So, before calling pinMode to change INPUT to OUTPUT one should call digitalWrite(input pin, LOW) to make sure the pullup is disconnected? Not sure it matters, but curious.

Exactly, not sure it matters. The internal 20-50K pullup only uses 0.25mA or less of drive capability, so if you forget to disconnect it, it won't be as issue.
If running off batteries & looking for longer life, then turning it could matter more.