Digital 0 pin (RX) limited to serial?

Hi!
I have a little question : Is the digital 0 (RX) pin limited to do serial, or can it read digital input (for example from a button) like the other pins?
I couldn’t get it work. (I use TX only, so I though I could have one more digital pin…)

Thanks!

Yes it can function as a normal digital pin, but if you have the USB cable attached and communicate via serial you cannot use it as an additional I/O.

/me

Thanks!
But I don’t understand why this doesn’t work then:

int ledPin = 13;                // choose the pin for the LED
int inputPin = 0;               // choose the input pin (for a pushbutton)
int val = 0;                    // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare pushbutton as input
}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPin, HIGH); // turn LED ON
  }
}

(External power supply, no USB attached)

What is the result? What is the hardware?

/me

The hardware is a button wired like in the example to a Diecimila. It works on other pins (if I change 0 to 9 for example). I uploaded now this simple sketch instead of mine to see if the problem was in my code but…
The 13rd pin led does not go on at all.

Thanks for the help!

The problem is likely that digital pin 0 is still connected to the FTDI chip through a 1K resistor. Depending on how your button circuit is configured this could cause problems and prevent the state change.

You’d be much better off using any of the other digital pins besides 0 and 1. If you’re desperate for pins you can also use the analog pins for digital input. You can reference them as pins 14-19 (which refer to analog 0-5) and do the same pinMode() and digitalRead() calls.

Ok, then it’s perhaps because it’s connected to the FTDI chip.
The point was, I’m making a controller with 6 potentiometers and 13 buttons, so I wanted to be sure that I can use the 0 pin for a button. Otherwise, if I need more potentiometers or buttons I will use multiplexers and shift register.
It will be a standalone Arduino without USB connection, so no problem at the moment.
Thanks for the explainations!

You usually don’t need multiplexers and shift registers to deal with 13 buttons. You just need to wire them in a matrix format instead of solitary. Thirteen buttons should be done in 3 rows of 5, from 8 input pins. The only reason to do solitary format for many buttons is if the user should be able to press any multi-button chord they choose.

Hm, that’s interesting! If I can use it it should save pins I could use for LEDs!
I found this > http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239147759/1
It this what you mean? But I understood it uses an analog pin, right? (I need all the analog pins, otherwise I will have to buy a multiplexer)

In my case, I need to push some buttons together. I have the following buttons:
+

1 2 3 4 5
A B C D E F
I need to be able to push + and - together, and A2+ for example. I don’t need all numbers together or all the letters together.

Could you suggest me a tutorial?

Hi, I think I figured out how it works:

Is this ok for 6 buttons?

Sorry for the quality…

I could test it out, it’s working with this matrix. Thank you!