Be very careful remembering which to use under which conditions, as reading the wrong register is the cause of more than a few beginner program problems. PortD is primarily for controlling the port when it's configured as an output (DDRB == 1) As setting portb will change it from sourcing to sinking curent. When DDRD == 0 (set to input) portD controls weather or not the internal pullup resistors are enabled or not (1 == pullups on, 0 == pin is floating) PinD is a direct access register to the logic state of the pins. When DDRB is set to 0 you read the pin register to read the state of the pin. So remember, DDRD is for setting input/ouput PORTD is for setting I/O source/sink and individual pullups, and PIND will always return the current logic state of the port (mind you this can detect short circuits in or out of an I/O pin if the pin port is exactly opposite of what it's supposed to be)