Using one pin, for two ouputs, via another component such as a microcontroller ?

Hi all,

For sack of simplificty, I will only describe the essential here :
I am using an Arduino Nano (same idea with Arduino Pro mini), a stereo MSGEQ7 breakout board and a LED graph bars for a small project.

The MSGEQ7 board provides me with two numbers, one for left audio input, and another one for right audio input, audio coming from an audio jack.

Depending on the value of the left audio (for the moment, only the left), I light one led graph bars accordingly. Till here, no issue.

However, I want to light one led bar graph for the left audio, and another led bar graph for the right audio, so basically, stereo mode. But I don't have enough pins (I use them for other stuff) and want to stick with a Nano or Pro Mini.

So I was wondering if there is any way of only using 10 pins (indeed, 10 leds on a led bar graph), but for 2 led bar graph, and independently (example : left audio value would be 600, right would be 200, so left led bar graph would have 6 leds ON, and right one would have 2 leds ON, using in total only 10 pins on the arduino).
Either via some components such as diode etc, or via a microcontroller (nothing too fancy, I only need it for that) and nothing too difficult to program (I am still a novice in arduino).

Do you see what I mean ?

Thank you very much for your help!

day

edit :
1-not sure if led bar graph can be 'used' the same way as leds, I mean, the wiring will be less flexible with led bar graph, or not ?
2-Is it possible to control 2 leds from one pin? - Interfacing - Arduino Forum this seems to be a similar question, but I don't really see it as solved
3-I heard about Charlieplexing, wouldn't that be too complex for this ?
4-would 74HC595 help here ? easier, simplier, faster, cheap and would do the job ? if so, are they easy to program (if needed) or to use ?

So I was wondering if there is any way of only using 10 pins (indeed, 10 leds on a led bar graph), but for 2 led bar graph, and independently (example : left audio value would be 600, right would be 200, so left led bar graph would have 6 leds ON, and right one would have 2 leds ON, using in total only 10 pins on the arduino).

No. A given pin is either on or not. Whatever is connected to that pin is on when the pin is on, and off when the pin is off.

While it is generally true that a given pin is either on or not, there are ways around it.

Up to 25 LEDs could be scanned by using 5 pins + 5 pins = 10 pins, so 20 LEDs with 10 pins are possible. You have not told us whether your displays are 10 independent LEDs, 10 LEDs with a common cathode, 10 LEDs with a common anode, or something else.

There is a method called Charlieplexing that reduces the number of pins still further, because an individual pin could be high, low, or high impedance (also known as off or disconnected).

An easier concept to grasp is to use shift registers. This only uses 2 or 3 pins for an unlimited number of outputs. The challenges here are (1) additional parts are needed, and (2) Time is needed for the shifting. For 20 LEDs, 3 additional ICs are needed (but 4 ICs is conceptually simpler) and the time taken is probably insignificant compared to a human's reaction time.

The above methods will need some programming, of course, but you may be able to find code similar to your needs on the web. Whether they will work with your bar graph displays depends upon the displays which are a mystery at the moment.

And, of course, you could use two microcontrollers, one interpreting the left channel and one interpreting the right channel values.

Hi,

thank you both for your answers.

So 74HC595 and shift register seems to be an answer to my question, but still wondering if that would work with led bar graph and not leds as I see usually.

to answer you vaj4088, this is how it looks:


so not sure how to know if they are independent, common cathode, common anode etc. any hints on how to know that ? from what I see, they are 10 independent, but put together into one "box". I use 10 resistor and it is working.

I read about Charlieplexing, but it seems to be really too much for my use, besides, I saw some videos, and when it gets more complex, I could see a small latency, whereas shift register seem to do the job indeed.

But from I read, you say that shift register is also time needing ? what are ICs ?

I found 74HC595 wiring and code that would work, any thoughts: www.zem.fr/decouverte-du-composant-74hc595-8-bit-shift-register/

The 74HC595 shift register will allow you to drive up to 8 LEDs. To drive 10 LEDs you need to cascade two of them.

You say that you have run out of pins. Are you using the analogue inputs for anything ? They can also be used a digital IO pins. Have you got several switch inputs using individual digital pins ? If so you could use one analogue input and a resistor ladder to discriminate between several switches connected to the analogue input.

Hi.
Not sure if this will help, but if you can use two of these, then you only need 4pins for two bar graphs.

http://www.seeedstudio.com/wiki/Grove_-_LED_Bar

sold here,

http://www.seeedstudio.com/depot/Grove-LED-Bar-p-1178.html

It even supplies library and sketch.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

If you are controlling 10LEDs already with 10 output pins, then use the same pins to another 10LEDs but have a couple of transistors in their common circuit to multiplex them, one output pin can do the LED array select.

Tom.... :slight_smile:

@UKHeliBob : oh, nice catch ! I must have 2 74HC595 per led bar graph then (unless I use 4 of the leds, for two 74HC595 pins, eg. the two lower would always lit together, and two higher too).
Yes I use other pins for other "stuff" : UV meter, sound caption, potentiometer, clock, buttons to adjust the hours/minutes etc :slight_smile:

TomGeorge : well actually, that's even better, all in one, that's exactly what I wanted. I bought two of them.
I hope I can desolder their ledbar and put mine as mine have 5 green, 2 orange and 3 red, which I prefer to theirs (7 green, 1 light green 1 orange 1 red I think). Do you think that might be possible ?
Their library is even easier to use than what I thought.

I am off for the WE so I will try to provide you with a hand drawn circuit (I don't know how to use CAD and am bad at these..) however, it's a pretty "simple" one if you only need the led bar graph part.

finally, I did not get your last part, too 'techy' for me sorry. can you please develop just for my knowledge ? what's the purpose of transistors here ? how to create an array ? what would it look like in a code ? thank you

buttons to adjust the hours/minutes etc

Can you put several of them on one analogue input with a resistor ladder, perhaps ?

A 74HC595 is an IC (integrated circuit). You don't need 74HC595 and a shift register, because the 74HC595 is a shift register.

A jpg image of a component does not tell me anything about what is inside, so the photo you pointed me to is of no help. The photo references a web site that I cannot get to.

The shift register needs some time, but will be quite fast compared to a human's reaction time. It will work fine.

Because the 74HC595 has 8 outputs, three of the 74HC595 will be sufficient to drive two 10-LED bargraphs (with 4 unused outputs), but it may be conceptually easier to use two of the 74HC595 for the ten LEDs of the left bargraph (with 6 unused outputs) and use another two of the 74HC595 (cascaded from the first two) to drive the ten LEDs of the right bargraph (an additional 6 unused outputs for a total of 12 unused outputs).

By the way, unused outputs do not need to be connected to anything. They may be left open (unconnected).

The web site is in French and my French is poor. It looks like it could be helpful.

Charlieplexing looks complex but saves more pins compared to the usual multiplexing or scanning. The 74HC595 uses just a few pins for any number of outputs, but trades off time versus the number of outputs. YOU will have to make the tradeoff between complexity and number of pins.

I don't know what "WE" is, but have a good time!