hey so i have a duemilanove and i'm trying to use input buttons on pins 0 and 1. I have the code configuring them as inputs and I have the switch circuit with a pullup resisitor all working on every other pin except for 0 and 1. I realize that these are connected to USB so i tried powering it with a wallwart and had a little success with pin 1 but none with pin 0. The thing is that these pins keep giving me a value of 1, so i feel like the pin is reading some voltage but that it isnt the ones that im sending it.
If you have a look at the schematic of a duemilanove, you'll find that pin0 and pin1 are connected to the usb interface chip by 1k resistors. Even if you power the board externally, this chip gets powered too and is active. Pin0 is the chip's TX pin (goes to the atmega's RX pin) and it controls the state of that. This will always conflict with any signal you apply yourself.
is there a way around that? like can i cut a trace or apply more voltage or something? After i load the program i dont need that pin connected any more ever again right?
im just confused because i looked at the schem and pin 1 is also connected but it is now working.
Pin1 is controlled by the arduino chip and the usb chip just listens to it and doesn't control the pin's state, with pin0 it is the other way round.
Of course you can cut a trace, but that would permanently disable the USB upload (and waste about 5$ for the USB chip and connector).
You may overpower the the signal on pin0 if the voltage source is of lower impedance than 1k, like if you connect pin0 to GND with a 0.5k resistor. If you connect other high impedance circuitry to pin0, you may succeed if you put e.g. 2 inverters in series (like 74LS04) with it and connect that to pin0. They should be able to fight against the 1k resistor.
I haven't actively checked it myself (by looking at the core code), but it should be a fact that as soon as you use
Serial.begin(xyz);
Serial.print();
...
pin0 and pin1 of the duemilanove board are automatically set to input (RX) and to output (TX). at least that seems to make sense.
I think you need to stay away from using the arduino hardware serial functions if you want to use pin0/1 as normal I/O pins. Unless of course you want to delve deeper into the inner workings of the chip. Then you can disable the serial hardware in the chip as you like. It may be reactivated in the background as soon as you use any of the serial functions again. Some of the code experts will know this.