Arduino LED Bar Graph with a 4017 Counter and Potentiometer

In this tutorial I will show you how to drive a LED bar graph using an arduino and a potentiometer. This is fairly easy to do and a nice tutorial about it already exists on the arduino website. This tutorial will be different in that we will use a 4017 counter to save pins from the microcontroller. Additionally, I will demonstrate the concept of “persistence of vision”.

See below a video of the circuit in action.

If you are able to reproduce this project, have any question, correction, or suggestion, please, let me know by leaving a comment.

Hardware Required

Arduino board

(1) Rotary Potentiometer

(1) 4017 Decade Counter

Breadboard

Some wires

Schematic

(Click the image to enlarge)

This is how it works:

The 10 LEDs are wired to the outputs of the 4017 counter. There is no need to protect them with current limiting resistors because the maximum current per pin is 10 mA. The arduino controls the 4017 counter using just 2 digital pins: digital pin 2 is connected to the counter’s clock pin, and the digital pin 3 is connected to the counter’s reset pin. The arduino runs a program that reads the analog input from the potentiometer (returning a value between 0 and 1023). The value read is mapped to the range 0-9 and is used to decide the number of LEDs to turn on.

Using the counter we face the limitation of not being able to turn on more than one LED at the same time. To solve this, we quickly turn on/off the LEDs in succession, and thanks to the ”persistence of vision” effect, all the LEDs appear to be on at the same time.

Hello Alex.
In theory the led bargraph shouldn’t dim when each additional segment is lit because they are not lit at the same time. They are multiplexed and due to the persistence of vision effect “they seem” to be lit at the same time.

OK, that works, but if you had 20 LEDs could you string together 2 4017 counters and make it work as one longer bar graph for more precision? Or would 10 be the limit? And if 20 is possible, where’s the limit? Just wondering, this brought up some fascinating possiblities.

Sorry for my late reply.
It is not easy to do that programatically using the constructed circuit. Why: (1) persistence of vision will get in your way. (2) the code you have provided does not help much to acomplish that.
My code works because it reads the value of the pot in realtime and turns on the LEDs accordingly. So if at a given time the pot reads 8 then the first 8 LEDs will be lit. Later if the pot is gradually turned to 4 you will see the bargraph going in reverse ending up with 4 LEDs lit.

Unquestionably consider tyat that you stated. Your favourite
reason appeared to be on the internet the easiest thing to be mindful of.
I say to you, I definitely get irked while other
folks consider concerns that they plainly don’t recognise about.
You managed to hit the nail pon the top and outlined out the
entire thing without having side-effects , other
folks could take a signal. Will probbly be again to gett more.
Thanks

is implementing – Foreclosure Diaries, a documentary regarding the financial disaster and possesses blogged on foreclosure related issues for American Banker game stefen wisniewski oakland raiders road jersey 61
nike mens nfl white the sites in most cases
keep quote for you personally and lock the quote in for a couple of days.