I have to manage one single analog pin with other digital IO.
I am using a PIC micro, where I have utilized all the pins and I want one more pin for analog input. At the current stage, I can not really afford a new controller design for my project.

I have assigned 7 pins for 7 segment and the other pins are assigned to LEDs, which is a must.

I am looking for multiplexing circuit design (using transistor or something) where I can multiplex analog input and digital output in the design.

I will be connecting an LDR to the analog input.

  • \$\begingroup\$ it may be possible to use a LED as a light detector. \$\endgroup\$ Aug 3, 2019 at 8:44
  • 1
    \$\begingroup\$ Let's see your circuit schematic. You have several options for feeding two LEDs from one GPIO. See LED GPIO tricks. \$\endgroup\$
    – Transistor
    Aug 3, 2019 at 9:37
  • 1
    \$\begingroup\$ In general it is easier to multiplex multiple digital pins (input or output) then messing with an analogue pin. "and the other pins are assigned to LEDs" So maybe you can charlieplex your LEDs and reduce the pin count of that enough to have a dedicated analogue input. \$\endgroup\$
    – Oldfart
    Aug 3, 2019 at 14:41

1 Answer 1


just connect both...


simulate this circuit – Schematic created using CircuitLab

So long as you are not doing charlieplex the LDR circuitry will not be disturbed by your LED multiplex, and the LED multiplex will not be disturbed much by the LDR.

  • \$\begingroup\$ Won't your LED switch On during high light situation? \$\endgroup\$ Aug 4, 2019 at 10:28
  • 1
    \$\begingroup\$ not visibly :) (also you only need a few microseconds to read the light level, drive the pin low when you don't want the LED. if the LEDs are multiplexed then drive the other end high (or leave it open-circuit) when reading the brightness \$\endgroup\$ Aug 4, 2019 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.