I have 4 pairs of "LED + LDR" sensor. I need to be able to switch each of them on/off independently and take reading from the LDRs. To connect all of them to the microcontroller board, I would need 4 output pins for the LEDs, 4 output pins for the LDRs and 4 input pins for the LDRs. The output pins (also the power supply for the components) turn the LEDs and LDRs on/off while the input pins measure the current/voltage from the LDRs. My microcontroller board has only 12 input/output pins, how do I minimize the pins usage? I know the LDRs can be connected to a single input pin via a multiplexer but how do I connect the output pins to the components? A schematic diagram would be very convenient. Thanks.
IMG http://i65.tinypic.com/2liblvm.jpg I came up with this circuit. 4 pins are used. Note: I didn't include the clock connection for simplicity. The microcontroller board has a dedicated output pin of its clock, hence this would not affect the amount of input/output pins used up.