3
\$\begingroup\$

Im tying to build a little meter type display on my arduino using this 10 bar LED display thing.

https://www.amazon.com/gp/product/B07BJ8FDT4/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

However the problem I'm running to is that I dont have 10 pins to spare to control each of the LED individually. From looking around I think a IC chip might be my best option. But im not sure is there one that output an increasing number of pins depending on a voltage of a single input pin? Or is there a better way to do this?

Thanks

\$\endgroup\$
1

3 Answers 3

4
\$\begingroup\$

As ErikR noted, you only need 4 GPIO's to control up to 12 LEDs using a technique known as charlieplexing.

schematic

simulate this circuit – Schematic created using CircuitLab

To turn on LED D9

pinMode(0, INPUT); // tristate as not used
pinMode(1, OUTPUT);
pinMode(2, INPUT);
pinMode(3, OUTPUT);
digitalWrite(1, HIGH);
digitalWrite(3, LOW);

In real code you'd use some suitable data structures to avoid the code repetition the above implies.

Some examples

The second example is more advanced but could be used if you want multiple LEDs illuminated at the same time (bar vs spot graph).

\$\endgroup\$
4
\$\begingroup\$

Actually chips that can drive bar graph LEDs based on input voltage do exist. They are called bar display drivers so you can search for them.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ The most well-known of this kind of chip is perhaps the LM3914. \$\endgroup\$
    – ErikR
    Jun 9, 2021 at 6:51
2
\$\begingroup\$

You could use a shift register like the SN74HC595 SN74HC595 to expand your port numbers.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.