Internal port D pullup resistors when set as input

I used a simple program for my Uno so that PORTD was configured as inputs with the pullup resistors as follows:

void setup()
DDRD = B00000000; // set PORTD (digital 7~0) to inputs
PORTD = B11111111;//set all input pins high

void loop()

I noticed that when applying a short circuit to each of the inputs I was able to measure with a multimeter a significant differences in current.

Digital pins 2 to 7 measured about 0.15mA
Digital pin 1 (Tx) measured about 3.3mA
Digital pin 0 (Rx) measured about 8mA

This shows that the pullup values for pins 2 to 7 were about 30k ohms
and the pullup values for 0 and 1 (and in particular pin 0) were significantly lower.

I was drawn to this as my circuit has 8 optocouplers connected and I was wondering why there was such a variation in the voltage as measured at each input when operational. It still works well but could be a problem with optocoupler variations. I am thinking of reducing the optocoupler diode resistor value relevant to pins 0 and 1.

Are others aware of this situation?


Most probably you measured on RX/TX the output drive capabilities of the ATmega and the USB controller. But TX should source more than 40mA when configured as an output (after Serial.begin).

I haven't involved the Serial.begin (I don't need serial monitor info) as I was aware it could compromise any normal port input activities so in effect it is still configured as an input. Yes, pins 0 and 1 are connected to other components.

If I comment out the line which sets all inputs high then pins 0 and 1 sit at 5V. Short circuit current at these pins are the same independent of whether these 2 lines are with or without pullup resistors.

It's a shame that there is no 8 pin port available on the Uno free of other components for port manipulation software. However, in my application, I get around this by ensuring that the external circuit connected to these pins is capable of causing a change of state.