LED switching question

Started by Mialbu, July 18, 2018, 12:26:58 PM

Previous topic - Next topic

Mialbu

Hi all,
I'm trying to switch between LEDs on a tri colour (4 lead common anode). Basically the pedal has two 3pdt switches and I was aiming for switch 1 on = red, 2 on = green, both on=blue.
I'm sure it must be possible but I've been toying with different ideas and transistors as an AND gate, but can't work it out.
Any ideas?
Thanks. M

EBK

I'm guessing you have no interest in:
1 on = red
2 on = green
Both on = yellow

Right?
  • SUPPORTER
Technical difficulties.  Please stand by.

marcelomd

#2
truth table:

input |  output
X | Y | R | G | B
0 | 0 | 0 | 0 | 0
1 | 0 | 1 | 0 | 0
0 | 1 | 0 | 1 | 0
1 | 1 | 0 | 0 | 1


The trivial answer:
R = X and !Y
G = Y and !X
B = X and Y
Three AND gates and two inverters should do it.

You can probably optimize it with a XOR/NAND gates or clever transistor use. OR... a microcontroller =)

edit: Transistor/diode logic
Not gate:
And gate:

diffeq

#3
Quote from: Mialbu on July 18, 2018, 12:26:58 PM
Hi all,
I'm trying to switch between LEDs on a tri colour (4 lead common anode). Basically the pedal has two 3pdt switches and I was aiming for switch 1 on = red, 2 on = green, both on=blue.
I'm sure it must be possible but I've been toying with different ideas and transistors as an AND gate, but can't work it out.
Any ideas?
Thanks. M
AND gate is the right thing for the job, and I suggest using an IC for that. Search for binary decoders to get the general idea. I've thrown together a quick schematic to show the idea, using two CMOS ICs, 4049 inverter & 4081 quad AND gate. In here, 4049 inverter is also used to light up LEDs, being connected to cathode:



EDIT: Looks like Marcelo beat me to it  ;D

Quote from: EBK on July 18, 2018, 01:18:26 PM
I'm guessing you have no interest in:
1 on = red
2 on = green
Both on = yellow

Right?
That would be too easy then, wouldn't it?  ;)


ElectricDruid

It could be done with pure NAND gates too, but it doesn't save any chips - you need eight gates, so two chips, the same. I'm basically replacing the inverters with NAND-wired-as inverter and swapping the !X and !Y logic over to reflect the fact I've used NAND not AND.

R = !(!X NAND Y)
G = !(X NAND !Y)
B = ! (X NAND Y)

Red and green need three gates, and Blue only needs two.


PRR

#5
One (cheap) chip. Check my logic. (Ooops, got switches backward...)

  • SUPPORTER

Mialbu

Thanks for all the suggestions - plenty to try out! I did try a bicolour with red/green and both for yellow, but the yellow colour didn't look much different from the green.

EBK

#7
Quote from: Mialbu on July 19, 2018, 08:08:48 AM
Thanks for all the suggestions - plenty to try out! I did try a bicolour with red/green and both for yellow, but the yellow colour didn't look much different from the green.
A smaller resistor for the red element, or a larger resistor for the green one could help change the mix to a more distinct yellow/orange.

Still, nothing wrong with pursuing the RGB idea if you prefer that.
  • SUPPORTER
Technical difficulties.  Please stand by.

Mialbu

Hadn't thought about colour mixing with resistors. Will give that a go too. I've got a 4511 in the parts box. Based on PRRs idea I might be able to hack two inputs into 3 LED outputs if there are enough unique positions in the output table.

merlinb

#9
I am always amazed at the over-engineering that happens on this forum...   Stick to the KISS principle! Switch off your digital brain (any fool can count to 1) and switch on your analog brain instead!

This does exactly what you want. It works because blue LEDs have a larger forward voltage than red or green, so blue will remain off even when it is in parallel with them. You can adjust the three resistors to get whatever brightness you need from each colour.

EBK

#10
Quote from: merlinb on July 19, 2018, 09:08:45 AM
Stick to the KISS principle!
For a second there, I thought you were telling everbody they should always do what I say (my last name just so happens to be Kiss)!  :icon_lol:

It naturally follows that I always stick to the Kiss principle, which often conflicts with the K.I.S.S. principle.  :icon_rolleyes:
  • SUPPORTER
Technical difficulties.  Please stand by.

marcelomd

Quote from: merlinb on July 19, 2018, 09:08:45 AM
I am always amazed at the over-engineering that happens on this forum...   

What are you trying to do!?! Go away with your simpler, smarter and elegant-er solutions! Shoo! shoo!  :icon_mrgreen: