0
\$\begingroup\$

I once saw somewhere that it is possible to control 3 LEDs with 2 IOs and only using LEDs and resistors. The high state is 5v and low state is 0v.

With 2 digital IOs, we can have 4 different possible situations for LEDs.

00 -> all off
01 -> LED1 on, others off
10 -> LED2 on, others off
11 -> LED3 on, others off

So it is logically possible using logical gates and mixing them. but How could it be done only with resistors and LEDs? and I am sure this method exists.

If they were 2 It was so easy. we connected them the in opposite to each other in parallel with a series resistor and 01 would light the first one and 10 would light the other one. like this :

led

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

If both IO lines have the same logic level then neither of the two LEDs would light so you use this to control a 3rd LED but I think you need two diodes acting as a sort of AND gate: -

schematic

simulate this circuit – Schematic created using CircuitLab

If either GPIO line is low then the LED won't light. If both GPIO line is high then the LED lights.

\$\endgroup\$
6
  • \$\begingroup\$ why not replace one of the diodes with LEDs? they are anyhow a kind of diode! \$\endgroup\$
    – AHB
    Commented Jan 4, 2016 at 9:19
  • \$\begingroup\$ @BlueSky The diode needs to have a much lower volt drop than the LED to prevent the LED from illuminating. \$\endgroup\$
    – Andy aka
    Commented Jan 4, 2016 at 9:21
  • \$\begingroup\$ For the other 2 LEDs can I use the schematic in my question? \$\endgroup\$
    – AHB
    Commented Jan 4, 2016 at 9:27
  • \$\begingroup\$ @BlueSky yes you can. \$\endgroup\$
    – Andy aka
    Commented Jan 4, 2016 at 9:32
  • \$\begingroup\$ @BlueSky, ... and set R1 to match the R in the other pair to give same brightness - 330R in your example. \$\endgroup\$
    – Transistor
    Commented Jan 4, 2016 at 9:40
0
\$\begingroup\$

if you want to use only resistors you can do it like this.

schematic

simulate this circuit – Schematic created using CircuitLab

as VCC is 5V the bleed resistor parallel with D3 is needed suffifient that it does not light.unless both in0 and in1 are high.

\$\endgroup\$

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.