Maximum number of colors from a LED using only 2 pins! (NO MCU!) - Page 1
Forum section: electronics / beginners

author: oliv3r
author_rank: Frequent Contributor
timestamp: October 05, 2023, 08:25:14 am
content: So first off, this is a non-micro question. So no charlyplexing or other fancy stuffI have a plug and a socket. On the socket, I want to mount some LEDs. On the socket, I only have 2 pins available LED1 and LED2, but on the inside of the socket, I have GND, -2v5, +2v5 +4v0 available. Those powers are also exposed on the socket and thus available on the plug.So a 6 pin connector.I want to have several plugs, where each plug is wired in a different combination to light up the leds. So the idea is, if I plug in connector 1, I get (for example) the RED led on, connector 2, the GREEN led, connector 3 (depending on how i wire things up) an ORANGE led (Green + Red). So this is just my dumb and simplified view of the world. I was thinking of using a bi-color led, but with common anode (or cathode), which thus would also me to have the 3 mentioned colors, as I could drive the led from the connector in the different configurations.But this is where my box of tricks runs out. E.g. what if I connect 2 bi-color leds, one common anode, one common cathode?e.g. the following:But now we have a current path through both resistors and both diodes, lightening up everything, which might be fine for a default indicating the 'unconnected' state.using, CD1- @ 4V, CD1+ @ GND, would light up the two bottom leds, vice, versa the two top leds. Leaving one unconnected, would light up 3 leds. So then there's probably no advantage of using just 2 leds or a single bi-directional.Any other thoughts and idea's to get slightly more leds/combinations then just using a single bi-color led?What 'pit falls for young players' am I overlooking :pP.S. in terms of purchasing, going with a single RGB LED is probably a lot cheaper, and I'd end up just using 2 colors out of 3 ...P.S.S. Thinking about the RGB led, I could do something with a NAND gate, and if nether G or B are being being supplied, then R could be. so that RED is unconnected, G or B, G+B are then the 3 combinations, if that makes sense. Can I just take the 4V comming in on the CD1+ or CD1- pin, feed it through a current limiting resistor and connect it to a NAND gate (and abuse the same resistor :p)?(I realize my led is in the wrong direction :p, but would this even work?

author: sparkydog
author_rank: Regular Contributor
timestamp: October 05, 2023, 08:02:14 pm
content: "no micros" is a very non-specific requirement. Are we allowed to filter the input for specific frequencies and use AM/FM on multiple carriers to modulate R, G and B? We've been separating out signals long before MCUs existed. Can an MCU be used to drive the inputs?At minimum, you can in theory get "infinite" colors (or at least "lots") by having the inputs be analog or PWM rather than simple on/off.If yourinputscan be MCU-controlled, you can probably find existing addressable-RGB LED packages that will happily display "many" colors (at least 16^3, if not 256^3 or even more) without having to invent your own.

author: langwadt
author_rank: Super Contributor
timestamp: October 05, 2023, 08:08:48 pm
content: two leds in series between 2.5 and gnd, pin through resistor to mid point, pull high or or low to turn on an led?

author: tychob
author_rank: Contributor
timestamp: October 06, 2023, 01:02:48 am
content: You don't 'need' a MCU to get fancy. A couple of n bit shift registers, a couple of n bit counters, and a clock source, and you can implement SPI controlling n LEDs. Or you could use an MCU for less money and space.

author: golden_labels
author_rank: Super Contributor
timestamp: October 06, 2023, 05:49:34 am
content: No MCU, but a digital chip larger than some MCUs is acceptable? Seems pretty arbitrary and unneccessarily limiting.With two binary inputs you can get at most 4 colors, if no memory elements are used. This limitation comes from impossibility of encoding more states. All three solutions, that you proposed, are already at this limit. You can’t get better than that and the only thing you can choose is which colors to obtain.To get beyond the limit of 4 colors, mult-level logic is required. As an example consider this layout:As long as D1 to D4 can operate from 2.5 V (red to some green), while D5 and D6 require higher forward voltages over 3 V (blue, single-LED purple and white, lower Vf in series), you can get 8 different settings(1)by driving inputs with three levels 0 V, +2.5 V and -2.5 V. Unfortunately diodes are still not controlled independently, so you can’t get the full R1G1B1 spectrum(2), and you can’t use 3-LED common-cathode/anode packages.Adding a +4 V signal may allow using common-cathode/anode packages and a bit of tint to colors, but controlling current becomes hard and one must watch for reverse voltage rating.(3)Adding LEDs from inputs to other power lines may allow adding a bit of a tint too.(1)The 9th option is black: all LEDs off.(2)3-bit color, one bit per channel.(3)If diodes are not paired in anti-parallel fashion, you get up to -6.5 V for some inputs.

author: oliv3r
author_rank: Frequent Contributor
timestamp: October 06, 2023, 06:50:58 am
content: Quote from: golden_labels on October 06, 2023, 05:49:34 amWell, sure, we can use a MCU, but the goal is just to diffentiate between various possible plugs, and keep it as simple as possible. That nand gate is probably more expensive then that 3 cent paduk :p but also cost software development effort etc. Also, both PCB's are all analog. A comparator and an opamp, so adding an MCU seems like a bit muchbut overal, that looks a lot like charlieplexing, and might be exactly what I want/need. I'll play with that thought a bit, as I do really like the idea. Even if it is just to drive the 3 colors of an RGB ...

author: Ian.M
author_rank: Super Contributor
timestamp: October 06, 2023, 07:51:28 am
content: A LM3914 Dot/Bar LED driver could be used in dot mode, to use an analog voltage level to select between ten different outputs. Combine these to drive a common cathode RGB led using nine PNP transistors (one of the outputs encodes 'OFF'), and various resistors and steering diodes to allow the individual RGB currents and thus color for nine of them to be freely chosen. The analog voltage is simply set by a potential divider, one element of which is a resistor between the two 'LED' pins of your connector.

author: LinuxHata
author_rank: Frequent Contributor
timestamp: October 07, 2023, 10:02:00 am
content: There are SMD LEDs which incorporate internal voltage detector and other circuitry, so they change their color according to the voltage applied. Unfortunately, I don't know their p/n, since they're usually inside solar chargers,etc.

author: oliv3r
author_rank: Frequent Contributor
timestamp: October 07, 2023, 10:45:46 pm
content: The led bar driver is actually quite a decent idea.For now, I've settled on 4 colors, unless I overlook something, which isn't as good as some idea's above, but not too horrible ...