1

I have a LED controlled by a microcontroller.

I want to know how I can bypass this microcontroller so that I can control the LED with a separate current. Would I use transistors to switch between the two controllers to prevent backflow damage to my microcontroller? If so how?

Chetan Bhargava
  • 4,612
  • 5
  • 27
  • 40
Michael
  • 9
  • 2

4 Answers4

2

Left circuit: If either controller wants the LED on, it turns on. High = 'on'

Right circuit: If either controller wants the LED off, it turns off. High = 'off'

schematic

simulate this circuit – Schematic created using CircuitLab

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842
1

You could probably use a open collector configuration.

schematic

simulate this circuit – Schematic created using CircuitLab

Something similar to this. Connect the microcontroller to one input and the other source to the other. Both inputs can turn the LED on.

Peter Karlsen
  • 2,024
  • 14
  • 19
  • I have another part to my question. If I had a continuous random 12V input at input_1, how can I isolate this input when a constant 12V input is supplied at input_2? Thank you again for your help. – Michael Mar 02 '14 at 20:31
  • If I understand it correctly, You want galvanic isolation between the two sources at input 1 & 2? Q1 and Q2 could be changed to a couple of opto couplers. That would probably do the trick. The resistors needs to be changed to appropriate values. – Peter Karlsen Mar 02 '14 at 20:56
1

How about if you wanted to control the LED from more that two places - how about 4. What about being able to reverse the demand from one input - how could you do that. I'm aware that this is beyond the scope of the question but it's fun to answer: -

enter image description here

This circuit can control an LED from 4 independent places using an analogue switch(es) to invert state previously set. For simplicity (2 sources) just omit the two middle sets of analogue switches.

It's also known as a 2-way light switch.

It's also know as an Exclusive OR gate so if you want to "reverse" the "demand" from source A, feed it through a 2-input EX-OR gate and have source B connected to the other input.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
  • Also interesting is that there is not a uniquely defined behavior for a "Exclusive-OR" gate with more than 2 inputs. http://electronics.stackexchange.com/questions/93713/how-is-an-xor-with-more-than-2-inputs-supposed-to-work – Spehro Pefhany Mar 02 '14 at 21:34
0

If the pins on your microcontroller can sink enough current to drive the LED (usually between 10 and 20 ma), then you don't need any transistors at all -- just two diodes. Check the datasheet for the microcontroller and look for I/O pins maximum sink current (low voltage). It is usually either higher or the same as the maximum source current (VDD voltage).

enter image description here

This should work with either open-drain or push-pull outputs. The diodes block the pins on one microcontroller from feeding into the other.

When sizing the resistor R1, you now need to account for the voltage drop across the LED as well as the 0.7v voltage drop across the 1N4148 diodes.

tcrosley
  • 47,708
  • 5
  • 97
  • 161