Question about using TX/RX pins as regular digital pins

Hello,

I would like to know whether it is possible to use pin 0 (RX) / pin 1 (TX) on an ATMEGA328P chipset (Pro mini arduino board 16MHz / 5V) as regular digital input ports at the same time.

My problem is the following : Since I run out of available ports on the arduino board, I would like to use port 0 and port 1 to connect two push buttons.

The issue is that these two ports are already used as TX/RX serial ports for the USB link to upload sketchs / print on the console for debugging.

When I connect the board to the PC to update sketch and debug it, the push buttons don't work as the port is "seen" as always ON.

I could imagine that once the sketch has been validated and I don't need USB link any longer, I could upload a final sketch with TX / RX ports as INPUT and push button would work...

My concern is : if I do that, would I be stuck afterwards when I want to use USB connection again? (TX not responding and impossible to communicate with the chipset?)

Thanks again for your support.

You’re misunderstanding something here, but I’m not sure what exactly you’re unclear on.

You should be able to put a push button on the pins on the Uno no problem. Use a normally open button and have it connect to ground when pressed (ie, normal best practice for push buttons). Then in your sketch, just don’t do Serial.begin()

When the buttons aren’t pressed, it’s just like a wire, so that won’t interfere with upload, and on the Uno, there’s a series resistor on the TX/RX lines (Between '328p and serial adapter) so you can drive the lines to ground (by pushing the button) and not harm the serial adapter.

On a '328p or other basic AVR (the 32u4 on micro/leo/etc is different), the chip is reset (reset pin capacitively coupled to the DTR pin of serial adapter) when serial connection is opened, and bootloader runs after reset - so the bootloader will run regardless of what unholy things your sketch does (you’ve reset the chip, and so your sketch hasn’t done whatever awful things).