Using multi-purpose pins

Hi,

I've got a project that uses all the pins on an arduino UNO. I really need one more digital I/O pin, my only option seems to be digital pins 1 or 0. The problem is that these are used as the Tx/Rx pins when upload code or monitor the output.

The question is, how can I use one (or both) of these pins AND still download code and de-bug my project?

Are you using the analog pins as well?
If you have used all the pins, use the RX/TX pins as outputs to transistors which then drive something else, or anything with a high-impedance input.
What do you have connected?

Are you aware that the analog pins can be used as normal digital I/O pins.

You can use external port-extender chips to get more I/O pins (sorry can't remember the chip name).

...R

74HC595-shift register for 8 outputs from 3 inputs

There may be a lot of room for optimization but there's no way to show you if you're not showing your setup.

(deleted)

4 digital pins are used for writing to an SD card, 6 are used for connecting to a 20*2 LCD screen, two pins are used to drive servos, and the remaining 2 are the Tx/Rx lines.

Two analogue pins are used for I2C comms, two are used for monitoring voltage and two more are used for a rotary encoder.

I'd like one more pin to connect a simple push button to.

Thanks.

LCD could be moved to I2C with a backpack, but it's not completely off limits to use pin 0/1 if you don't need them while uploading sketches.

Ok, more details for you guys. The device is actually an automated servo tester, the screen, rotary encoder and the new button I want to add are just there to navigate a series of menu options before the tests begin (select the servo type, the amount of logging and the test program etc). Once the menu options have been selected the button is no longer required.

Bearing this in mind, does this mean that I could connect one pin to both a servo and a push button at the same time? Initially the digital pin can be setup as an input, and used up to the point the testing starts, at which point it's re-configured as an output pin used to control a servo?

That would work as long as you don't press the button while testing.
You could use a shift register for the LCD.

You could use a shift register for the LCD.

Sorry, can you elaborate please? The libraries i've come across so far all use 6 pins for writing to the LCD

75HC595. datasheet

Fulliautomatix:
Sorry, can you elaborate please? The libraries i've come across so far all use 6 pins for writing to the LCD

This library REBL_UI does a lot of other things, but it also includes an LCD run from a shift register using the SPI bus. It only uses 4 pins.

Here's the schematic Ignore the button and encoder in the bottom right.

Here is a version of LiquidCrystal library that is set up to use it like that:GitHub - delta-G/LiquidCrystal_SPI_8Bit: LiquidCrystal library ported to use SPI and a shift register

See the documentation in the Github page in the first link for more information.