Building a circuit to multiplex between different devices on a single io pin

This is a hypothetical question.

Suppose I need Digital Pin 13 on an Arduino to be shared among 4 devices. Those devices don't need to operate simultaneously. However, I would like to be able to select which devices are allowed to run.

Could I use a Serial-In-Parallel-Out shift register in cascade with a De-multiplexer (and a pin for the control signal) to select which device to enable?

I don't readily have a demux & Shift register at hand so I can't try it out.

ElusivePi:
Suppose I need Digital Pin 13 on an Arduino to be shared among 4 devices.

Sorry, that is meaningless gobbledegook.

What do you actually want to do?

ElusivePi:
Those devices don't need to operate simultaneously. However, I would like to be able to select which devices are allowed to run.

What does that mean?

Paul__B:
Sorry, that is meaningless gobbledegook.

What do you actually want to do?
What does that mean?

Sorry, I'll try to be more specific.

Let's say I want to use D13 as a clock signal to an SD card, input pin for a button, the MOSI pin for an RTC module, and LED output.

Rather than dedicating a pin to each device when I know that my system will never need to run any permutation of devices simultaneously, couldn't I just:

  1. Dedicate one digital IO pin as the data pin (which will communicate with all four devices serially via SIPO shift-register). Connect this pin (call it D1) to a SIPO shift register.
  2. Connect the output of the shift register to the input of a demux.
  3. Connect a device to each demux output.
  4. Dedicate another digital pin to control which demux output to output to.

No, the same pin can in fact simultaneously be the clock signal to an SD card, the MOSI pin for an RTC module, and a LED output.

It might also just be able to be an input pin for a button.

The SD card and the RTC module only respond to this pin when they are enabled, and they are never enabled together, so that is not a problem. The LED will flicker somewhat as the SD card is read - access to the RTC module is so brief you would be unlikely to notice. You merely have to remember to set the LED status again immediately after the SD card or RTC routines.

If the LED has a current limit resistor of something like 2.7k and is connected to 5 V, you could use a 330 Ohm resistor in series with the pushbutton to ground so that by switching pinMode to INPUT_PULLUP, you can read the switch. This takes only 10 milliseconds for debounce and of course, the LED will light whenever you press the button.

Paul__B:
No, the same pin can in fact simultaneously be the clock signal to an SD card, the MOSI pin for an RTC module, and a LED output.

It might also just be able to be an input pin for a button.

The SD card and the RTC module only respond to this pin when they are enabled, and they are never enabled together, so that is not a problem. The LED will flicker somewhat as the SD card is read - access to the RTC module is so brief you would be unlikely to notice. You merely have to remember to set the LED status again immediately after the SD card or RTC routines.

To recap, you're suggesting that I can just connect each device to the same pin node and enable the devices as they are used. The shift register & demux are redundant.

That would be about the size of it.