Controlling 10 LEDs with only 4 current source (transistors, AND-, OR-gates ... i guess)

Thread Starter

gregor101

Joined Mar 20, 2017
2
Hi!

@ mods, admins: I hope this post suits in the category "Circuits and Projects / The Projects Forum". If not, feel free to move it elsewhere.


My name is Gregor and I am a total newbie in electronics.

I have a micro-controller-board with 14 digital outputs (outputs with either the value 0 Volt („0“) or 5 Volt („1“) ). I want to implement a visualization of the value of a board-variable with 10 LEDs in the following way:

If the value of the variable is '0', no LED should be on.
If the value of the variable is '1', the first LED should be on
If the value of the variable is '2', the second LED (or the first two LEDs) should be on.
If the value of the variable is '3', the third LED (or the first three LEDs) should be on.
......
.....
If the value of the variable is '10', all LEDs should be on.

A trivial solution, which I thought of, is to plug the 10 LEDs to 10 of the 14 digital outputs. The problem, however, is that in that case only four unused digital outputs remain.

Now, my idea is to use just 4 digital outputs, which should represent digits of a four digit binary number, which encode the (decimal) variable value as a binary number, which in turn determines which LED (or LEDs) should be on e.g. if the variable has the (decimal) value '6', which corresponds to the binary value '0110', then the output value of the second and third digital output should be „1“ (5 Volt) and at the output value of the first and fourth digital output should be „0“ (0 Volt). And now (in this case), since the output values of the four digital outputs represent the (decimal) variable value '6', the sixth LED (or the first six LEDs) should be on.

So far I have found out, that this could be implemented with an electrical network based on bipolar transistors, which should be used to build logical AND-, OR- and NOT-gates, but I have no idea how this can be done in detail.

I have the following prior knowledge:
*) I know that current is flowing from a source to a ground.
*) I know what an electrical resistance and a bipolar transistor are, how they work and how their corresponding symbols in a circuit diagram look like.
*) I know what a AND-, OR- and NOT-gate is.
*) I have basic skills in programming my micro-controller-board, in particular I know how to write to its digital outputs.

Further prior knowledge I don't have. I am, of course, thankful for any replies, but those wich would require additional knowledge / skills will, unfortunately, be of little help for my. In particular I can't estimate, what I will have to consider regarding voltage and current intensity. So I don't now, what to do to be be sure, that no transistor or the board itself gets damaged.

An additional circuit diagram, or a photo of a drawing of a circuit diagram, would be very(!) helpful.

I hope I have communicated my request as clear and unmistakable as possible, so that helping me can be achieved with the smallest time exposure as possible.

Thanks in advance for any replies!

Gregor
 

ronv

Joined Nov 12, 2008
3,770
Hi!

@ mods, admins: I hope this post suits in the category "Circuits and Projects / The Projects Forum". If not, feel free to move it elsewhere.


My name is Gregor and I am a total newbie in electronics.

I have a micro-controller-board with 14 digital outputs (outputs with either the value 0 Volt („0“) or 5 Volt („1“) ). I want to implement a visualization of the value of a board-variable with 10 LEDs in the following way:

If the value of the variable is '0', no LED should be on.
If the value of the variable is '1', the first LED should be on
If the value of the variable is '2', the second LED (or the first two LEDs) should be on.
If the value of the variable is '3', the third LED (or the first three LEDs) should be on.
......
.....
If the value of the variable is '10', all LEDs should be on.

A trivial solution, which I thought of, is to plug the 10 LEDs to 10 of the 14 digital outputs. The problem, however, is that in that case only four unused digital outputs remain.

Now, my idea is to use just 4 digital outputs, which should represent digits of a four digit binary number, which encode the (decimal) variable value as a binary number, which in turn determines which LED (or LEDs) should be on e.g. if the variable has the (decimal) value '6', which corresponds to the binary value '0110', then the output value of the second and third digital output should be „1“ (5 Volt) and at the output value of the first and fourth digital output should be „0“ (0 Volt). And now (in this case), since the output values of the four digital outputs represent the (decimal) variable value '6', the sixth LED (or the first six LEDs) should be on.

So far I have found out, that this could be implemented with an electrical network based on bipolar transistors, which should be used to build logical AND-, OR- and NOT-gates, but I have no idea how this can be done in detail.

I have the following prior knowledge:
*) I know that current is flowing from a source to a ground.
*) I know what an electrical resistance and a bipolar transistor are, how they work and how their corresponding symbols in a circuit diagram look like.
*) I know what a AND-, OR- and NOT-gate is.
*) I have basic skills in programming my micro-controller-board, in particular I know how to write to its digital outputs.

Further prior knowledge I don't have. I am, of course, thankful for any replies, but those wich would require additional knowledge / skills will, unfortunately, be of little help for my. In particular I can't estimate, what I will have to consider regarding voltage and current intensity. So I don't now, what to do to be be sure, that no transistor or the board itself gets damaged.

An additional circuit diagram, or a photo of a drawing of a circuit diagram, would be very(!) helpful.

I hope I have communicated my request as clear and unmistakable as possible, so that helping me can be achieved with the smallest time exposure as possible.

Thanks in advance for any replies!

Gregor
You can do it all with the micro.
You can define 3 outputs:
1-led 1 on
2-led 2 on
3-led 3 on
Then in code raise the appropriate output.
All off = 0
1 1 output active
2 2 output active
3 1 and 2 output active
4 1, 2, 3 output active.
Edit:
Sorry, you said 10 leds.
Same principal but the outputs are 1, 2, 4, 8. I'll post the logic in a minute.
 

Thread Starter

gregor101

Joined Mar 20, 2017
2
@ ronv: Thanks for the quick reply! Unfortunatly, I have absolutly no idea what you are talking about. In particular, it totaly contradicts my intuition, how this should be done only by programm code in the micro-controller. Maybe I didn't succeed in communicating my request clearly. Sorry, if so!

@ eetech00: One reason ist, that I don't know what "BCD" or "uC" means. "IC", I guess, means "integrated curcuit
 

ronv

Joined Nov 12, 2008
3,770
This was the circuit I was thinking about. But an IC might be better.
Anyway if output 1 is negative led 1 is on.
If output 2 is negative led 2 is on.
If output 1 and 2 are negative led 3 is on.
I hope I didn't misunderstand your request.

upload_2017-3-20_13-29-33.png
 

crutschow

Joined Mar 14, 2008
34,445
You could use four of the micro-controller (μC) outputs to generate a 4-bit BCD output (Binary Coded Decimal which is a binary number that goes from 0 to 9).
This output drives a CD4028 decoder, which has 10 outputs controlled by the BCD input.

You may need to add a transistor buffer on each output, depending upon the LED current you want since the 4028 can only drive a half mA or so, depending upon the supply voltage.
But a half mA may give you sufficient brightness for an indicator if its a high-brightness type LED.

Edit: Note that state 0000b gives output 0 as logic 1 (ON).
To turn off all outputs, as you wanted for one of the states, you can enter any number from decimal 10 through 15 (look at the Table 1 Truth Table).
 
Last edited:

eetech00

Joined Jun 8, 2013
3,951
@ ronv: Thanks for the quick reply! Unfortunatly, I have absolutly no idea what you are talking about. In particular, it totaly contradicts my intuition, how this should be done only by programm code in the micro-controller. Maybe I didn't succeed in communicating my request clearly. Sorry, if so!

@ eetech00: One reason ist, that I don't know what "BCD" or "uC" means. "IC", I guess, means "integrated curcuit
BCD = Binary Coded Decimal
uC = Micro Controller
IC = Integrated Circuit

There are IC's that convert BCD input to 7-segment display format so it can directly drive a 7-segment LED display.
So instead of lighting 10 leds and leaving the interpretation to the user, you would light a "digit" on a 7-Segment display.
You would need two 7-segment displays for your project.

Crutscow briefly mentioned what I had in mind in post #6.
 

absf

Joined Dec 29, 2010
1,968
You can decode the 4 bit port pins with 4514 and the 9 outputs go to 9x 4071 OR gates. The 10th output would go to the common of the OR gates.

Allen
 
Top