Switch between pinModes to save pins?

I have been working on a project that uses a lot of sensors, LEDs and other modules. However, due to limitations in size and budget, the only board I can use is Arduino Uno R3, meaning that the I/O pins are not enough.

In response to the issue, I came up with the idea to connect a button and LED in series to one pin (pin x) and switch between pinMode(x, INPUT) and pinMode(x, OUTPUT) when in need of controlling the LED or reading from the button.

I would like to know if it will cause any damage to my hardware (sensors, board, LEDs...), will it be feasible or are there better options to solve my problem.

Thanks in advance.

You only told us about one end of the two connections. What is connected to the other end of both the switch and the LED?
Paul

You may already know this, but the analog input Ax pins are digital pins too. If they're vacant, there's 6 more digital pins.

Other option is using port expanders, or bitshifters (personal favorite)

Hello
Post a design schematic of your project to see how we can help.

1 Like

Hi,
Can you please post a list of your input devices and output devices with links to data/spec.

What is the application?

Thanks.. Tom.... :grinning: :+1: :coffee: :australia:

consider buying a 16 IP-pin port-expander input/or output

https://www.google.de/search?as_q=MCP23017+cheap

https://www.google.de/search?q=SX1509+cheap

8 IO-pin output
https://www.google.de/search?q=74+595+cheap

https://www.google.de/search?q=arduino+mega+2560+cheap

endless status-information much more flexible than a LED
https://www.google.de/search?q=oled+128+x32+cheap

16x2 LCD
https://www.google.de/search?q=lcd+16x2+i2c+cheap

Amen to that. It should be a schematic of the proposed solution.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.