internal pullups enabled by default?

Are the ATmega's internal pullups enabled when pinMode is INPUT?


I seem to remember that the internal pullup is disabled by default, but if you want to enable it, you actually can do so using

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

i.e. you write HIGH to the pin as if it were an output pin, even though you have already defined it as input.

Can somebody confirm this with certainty?

You're right. Here's the relevant quote from page 50 of the ATmega8 datasheet:

"If PORTxn is written logic one when the pin is configured as an input pin, the pull-up
resistor is activated. To switch the pull-up resistor off, PORTxn has to be written logic
zero or the pin has to be configured as an output pin. The port pins are tri-stated when a
reset condition becomes active, even if no clocks are running. "