use of pin 0

In experimenting with using pins 0 and 1 for digital input and output, I am trying to understand the limitations on these two pins.

I know they are also used for TX and RX of serial data and so can not be used for digital I/O if also using Serial.* calls. I have a simple program with no serial functions being used and the Arduino (duemillanove) running on external power (with the USB cable disconnected).

In this case:

const int led = 1;
const int btn = 0;

void setup () {
  pinMode (led, OUTPUT);
  pinMode (btn, INPUT);

void loop () {
  digitalWrite (led, digitalRead (btn));

I always see the LED as HIGH. I can reverse those pins and use pin 0 for digital output and pin 1 for digital input, and it works fine.

But I have not been able to use pin 0 for digital input.

Is this the expected behavior?

Many thanks, .andy

How exactly are you trying to use pin 0 for digital input. With a switch wired between this pin and ground (0V) it should work. With a switch between this pin and 5V I can see it always reading high.

Pin 0 is driven by the FT232RL USB-to-serial converter so it will be high if you don’t pull it low through a switch. So your observations are not unexpected.

Thanks for the reply.

I thought in the usual way with a pulldown resistor on the switch. One side of the switch is connected to +5V and the other to the pin and a resistor tied to GND.

Circuit picture here:

Is that right for pin 0?

Due to the fact that pin 0 is being driven high through a 1k resistor by the USB serial chip means that you would have to use a switch to ground (active low) to use this as a digital input. The logic in your software would have to consider a high as the 'off' condition and low as the 'on' condition. So bottom line is that you can use pin 0 as a digital input pin but you are stuck with the polarity of the logic you can use.


It's not right for pin 0. A more accurate model takes into account the FT232 output pin and 1k series resistor. See here: Unless your (unspecified) resistor to GND is low enough (I'd say 100 ohms or less) the voltage divider formed by it and the 1k resistor is going to keep the pin high enough to read as a logic 1.

I'd recommend a pushbutton wired directly to ground on this pin if you want to use it as a digital input.

Many thanks to you both for the clear and generous info!