4 LEDs with 3 Pins

Need to power 4 LEDs separately, but only have 3 pins left on my ATtiny24.
Came up with this above configuration.

LED no. 4 (which is actually a photo MOSFET) has its reverse voltage rated at 5V.

Please let me know if this will actually work or if you have different suggestions.

Thanks!

That will almost work but will blow the Opto... You're almost Charlieplexing :slight_smile: You can drive leds pins with 3 pins :slight_smile:

Also, you can reduce it to 2 resistors if you place them in line with pin 5 and 7.

And do you need to power the leds at the same time? Because now you're limited. For visual led you can time-multiplex the leds but I don't know what you want to rive with the opto.

  • You could insert a 1N4148, or 1N914 [or similar], in series with the Opto [and the LEDs as well, since their reverse voltage may , also, be a problem. Both the 1N914 and the 1N4148 have a Maximum Repetitive Reverse Voltage of 100V – and, thus, will prevent reverse current in your circuit.
  • Or, you could run the ATtiny at a lower voltage.
  • Also, you need a series resistor in series with the Opto LED, else you will fry it!

As for your Truth Table, if ‘-’ is zero and ‘o’ is open or high impedance, then it looks good to me.

FYI: the symbol in your drawing of the TLP222G is quite wrong. Pictured is a Bipolar transistor, whereas the TLP222G has a MOSFET pair on the output.
TLP222G.png

Also, your diagram is a bit hard to read [at least it is on my Desktop Monitors], mainly because the Forum image upload code crunches the image down to fit in a restrictive area. So, the trick for getting the best clarity is to work within those confines. For example, I took your diagram and compacted it a bit and arranged it more in a landscape aspect [whereas your original diagram is very portrait. Portrait is far more vulnerable to the squeezing algorithm].

here’s the result:

3Pins_4LEDs_compacted&landscape.png

A series diode doesn't help for the reverse voltage. Because you only create a voltage divider with a leakage current. And you can't tell if the diode takes 90% or 1% of the reverse voltage across it.

But yeah, in reality leds can handle higher reverse voltages then spaced. Loads of designs have a higher reverse voltage. Not saying it's good practice. But I just think manufactures just can't be bothered to really test the limits and stick to the "proven" 5V.

A series diode doesn't help for the reverse voltage

Avalanche breakdown in a pn-junction is unlikely to cause damage at leakage current levels
and these moderate voltages, too little energy available to do anything.

I think I got it. No opto-frying with this setup.
Plus only one resistor for the 3 LEDs and one one 1,5k resistor for the opto.

I’m willing to risk the reverse breakdown voltage of the LEDs. However the opto is more important. I f the LEDs fail is not a big deal.

Thank you for the charlieplexing suggestion. With this setup there’s only one alternate path with two LEDs, namely

+++ LED1 >>> LED3 ----- (no resistor)

instead of

+++ TLP222G >>> R1K5 ------

If I understand correctly, in a charlieplexing setup current will not flow across alternate paths.
However, will this also be true if the alternate path has no resistors present?

3 pin 6 LED Charlieplex discussion on stack-exchange:

The low forward voltage of the IR led won't play well with other LEDs, note, you want the forward
voltages to be similar to avoid false lighting up (say two IR LEDs v. one blue LED - when the blue is on
there's enough voltage to light both IR ones as well).

forward voltage:

LED4 (opto)…Vf = 1.15 V

LED1 green … Vf = 3.30 V
LED3 blue … Vf = 4.00 V

I don’t understand yet, how will it be that current will flow through the opto path (green) and not through the two other LEDs (red path).

Note that the alternate path (red dashed line) has no resistors on the way.

ps. these LEDs will always light separately, one at a time

In this setup there is no problem. The LED with the lowest forward voltage is across two normal leds (I asume aka higher voltage).

But one question remains:
What are you driving with the opto? And is that device okay with not getting power 100% of the time. Or, if the opto is power, you wouldn't turn on the other leds (or at least not L2 or L1 and L3 together)?

  • very simple project, the attiny will drive the relays of an ABC pedal.

  • the leds are supposed to signal the current channel (A or B or C)

  • relay switching sends a pop sound to the speakers,
    so the opto is shorting (muting) the audio signal for a very short time
    (while the relays are being switched)

Okay, but note you're limited by which LED you can turn on while you use the opto :slight_smile:

yup, but not concerned about it, the opto will run for 40 ms only. plus i can’t see the leds anyway.
at that point my foot is in the way :slight_smile:

what i noticed though, is that other muting circuits use much higher resistors for the TLP222G. I calculated 560 Ω based on the attached datasheet

designs such as this one, use much higher 1,5 kΩ resistors

http://stompville.co.uk/?p=423

TLP222G_datasheet_en_20170710.pdf (350 KB)

LEDs 1&3 are in series without a resistor! Keep original schematic and put a resistor in serie with pin 5 and another in series with pin 7.

Mm, yeah, can go wrong. But if L1 and L3 both have a Vf of 3V it’s fine.

thanks for the tip!
did a simulation and indeed didn’t work as expected.

came up with this new configuration instead.
prefer this over the original: no reverse current on the opto.

orinocopaul:
did a simulation and indeed didn't work as expected.

Most Arduino simulators are just a piece of crap...

What kind of leds are you planning to use?

But yeah, adding a third resistor is an easy fix :slight_smile: And probably the leds are visible with 560Ω as well which would make it an easy "3x the same resistor"-job.

breadboard simulation. with volts :slight_smile:
used a red led instead of the opto

for led 1 and led 3 will use blue and green
(for their larger forward voltage)

Is there a reason your not just using a 1-4 SIPO shift register? Data, clock and lock so just needs three pins and you can have any combination of those LEDs on.
https://www.jameco.com/z/CD4015-Major-Brands-4-STAGE-STATIC-SHIFT-REGISTER-DIP-16_12706.html?CID=GOOG&gclid=CjwKCAiA3vfgBRB9EiwAkfpd3FReZ9n31fnqKERebZHCxvEmvlUNjikcwWWRqSun0LV6uaouQKV2ahoCWuQQAvD_BwE

Slumpert:
Is there a reason your not just using a 1-4 SIPO shift register? Data, clock and lock so just needs three pins and you can have any combination of those LEDs on.
CD4015B: Major Brands : IC CD4015 4-STAGE STATIC SHIFT REGISTER : ICs & Semiconductors

Corrected link.

Why suggest an obsolete part? We are using a modern microprocessor here; the proper part would be a 74HC4015 but this is not available at Jameco, no doubt because its only use - the CD4015 that is - is for single chip fault replacement in old (pre-microprocessor) equipment.

But even that is the wrong function - it is not latched and inappropriate outputs appear as the data is clocked in (which is no doubt, why the 74HC4015 is not as readily available - and five times the price :astonished: ). It would not matter for the indicators, but it does for the mute function.

The correct part as so frequently referred to here, is the 74HC595 and it turns out it is the same price! :grinning: It is an octal latched shift register, controlled with three pins

Exactly!

Even better would be if he could use the extra outputs on the 595 to control some of his existing circuits. Maybe even free up the two extra lines needed to fully control the startup of the 595.