A very confusing misconception is floating around out there on the ether. As the subject line says, there can exist no such thing as a tristated input. Only outputs can be tristated on or off.
Just because a port pin's DDRn bit is written as a '0' does not necessarily make the pin an act as an input. If the PORTn bit *also* has a '1' written to it, then the pin will be a tristated-off *output* pin ! Kudos to the chip designers who eliminated the need for a whole separate tristate control register ! They designed each pin so that writing a '1' to a pin that is configured to be an input is used to control the output tristate option. Very clever ! After all, writing *data* to an input pin makes no sense at all, but writing *control data* to that input PORTn pin is very useful and is usually required.
Other much glossed-over points: A pin *always* has the internal pullup resistor attached to it despite its particular configuration. There is no way to disconnect it ! Additionally, an input pin can not have a "default state". Only outputs can have that. When a pin configured to be a tristated-OFF output is "read", of course the data comes back as a '1' - the input pullup resistor attached to the pin forces it to be read as a '1' value. Similarly, reading in data from a tristated-OFF output pin doesn't make sense, either. (Reading in data from a tristated-ON output pin does have its uses. That tells you what was last written to the pin.)
So a revised pin configuration chart looks like this:
When these values are *written* to these registers:
DDRn PORTn Pin Configuration ---- ----- ----------------- 0 0 An Input with a pullup resistor. Subsequent PORTn reads will reflect the external logic level being applied to the pin. 0 1 An Output which is tristated OFF. (AKA in the "hi-Z" output state) 1 0 An output pin with the value of '0' being applied to the external world by the uC. 1 1 An output pin with the value of '1' being applied to the external world by the uC.
So, configuring a pin to be an output is easy: Simply write a '1' to its DDRn. Subsequent writes to its PORTn will force that data to be put on the pin's output.
*Properly* configuring a pin for input requires 2 (two) register configuration writes: Write a '0' to DDRn to set the data direction to "input". Also be sure to write a '0' to PORTn to make sure that the pin truly operates as an input and not a tristated output. Not doing this 2nd pin configuration write could easily ruin your day !