Direct Port Manipulation with PORTD ( 328p )

You can take over PORTD, with the following caveats:

PD0 will be connected to TX line of serial adapter through a resistor (1k IIRC); the other end of this resistor is held high. You must make sure that this will not pose a problem.

In order to upload sketches, the serial adapter must be able to drive PD0 through that 1k resistor, and your controller must be able to drive PD1 high and low. You may need to provide a means to disconnect these pins from the rest of your project while uploading.

It doesn't matter what the code sets it to do - a hardware reset is performed (via DTR reset trick) to start the bootloader before it starts uploading, so the pins are restored to their reset state.

If you use Serial.begin() in your sketch, the UART functionality will take over PD0 and PD1 - in this case, DDRD, PORTD, etc will be ignored for those pins.