Arduino LED Bar Graph Driven by a 4017 Counter

In this tutorial, my primary objective is to show you how to make a simple LED animation using a LED bar graph and an Arduino. My secondary objective is to share with you a trick to save pins of the Arduino using a 4017 decade counter circuit. The video below shows what we will be making.

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

Hardware Required

Arduino board.

(1) LED bar graph (or alternatively 10 LEDs)

(1) 4017 Decade Counter IC

Some wires

Breadboard

Schematic

(Click the image to enlarge)

As you can see, using the 4017 counter we just need one digital pin from the arduino. Otherwise, we would need 10 pins from the arduino.

This is how it works: the LEDs of the bar graph are wired to the 10 outputs of the 4017 counter. The clock pin from the counter is wired to the arduino. When the arduino is running, it sends clock pulses to the counter making it advance. When the counter advances, the current LED is turned OFF, and the next one is turned ON. See below the picture of the circuit in real life.

(Click the image to enlarge)

Code

/*
* Simple LED Bar graph animation using a 4017 counter.
* The 4017 is used to save pins on the arduino.
*
* Developed by Leonel Machava
* http://codentronix.com
*
* This code is release under the "MIT License" available at
* http://www.opensource.org/licenses/mit-license.php
*/
/* PIN used to send clock pulses to the counter. */
int clockPin = 2;
void setup() {
pinMode(clockPin,OUTPUT);
}
/*
* Sends a clock pulse to the counter making it advance.
*/
void clock() {
digitalWrite(clockPin,HIGH);
delay(1);
digitalWrite(clockPin,LOW);
}
void loop() {
/* Send a clock pulse to the counter. It makes the counter advance
causing the current LED to be turned off, and the next one to be
turned ON */
clock();
/* Wait for 300 ms. */
delay(300);
}

NOTE: This animation can also be made using just a LED bar graph, a 555 timer, and a counter. My main aim in this tutorial was to share with the arduino fans how to make it using an arduino. Additionally, as said in the beginning, my secondary objective was to show a method of saving pins on the arduino, and I did it using a 4017 counter. An alternative way of saving pins would be through the use of 595 shift registers, but for this case it would not be better than using a 4017 counter because we would need 3 pins from the arduino and 2 shift registers.

If you like this article please share it by clicking one of the buttons below, follow me on twitter, or register on my RSS to receive article updates. Thanks!

I couldn’t make it work. I used 2 LEDs only and wired the 3rd pin to the reset. Only 1 LED was on.
One question I have: if I’m using 2 LEDs, should I wire them in pins “0″ and “1″ or 3 and 2 (matching IC’s pinout sequence)?

Thanks a lot for sharing this with all people you really understand what you are talking about!
Bookmarked. Kindly additionally consult with my web site =).
We could have a hyperlink exchange agreement among
us

I realize the power for the LEDs isn’t coming directly from the arduino now, but it is still a very bad idea to not have a current limiting resistor on an LED regardless of the voltage they’re being supplied with.

https://is.gd/35Jamo- – Consume adequate level of nutrients,
including fibers that reduce cholesterol levels, heart-healthy nuts, fishes, and low-fat dairy rich
in calcium. Everybody needs some pointers once and even though,
when your health are at risk then a stakes go higher.
When we travel as being a family we always have a kitchenette inside accommodation so that we can increase the risk for
most of our meals with food we all know after which have
one meal out every day.

heart health tips – https://is.gd/LwaBzV- – Biking is an excellent means
of workout that will strengthen your quads, improve blood
circulation and improve your stamina. Everything
in everyday life requires effort and sometimes these challenges could possibly be tough to
overcome. However, a toothache or any other dental problem doesn’t develop
overnight.

Consume adequate volume of nutrients, including
fibers that reduce cholesterol, heart-healthy nuts,
fishes, and low-fat dairy abundant with calcium.
It is significant that you just oversee the youngsters when they are brushing their teeth.

So far, exercise and balanced diets are believed as two of the most crucial factors conducive to strong and healthy body.

http://preview.tinyurl.com/y7pxa87a – Prevent ill
health – Modern medicine only focuses on treating us
if we are ill. Taking care of your teeth is surely an ongoing process and regular check-ups and cleaning with the dentist
prevents any long-term problems. Make jam and jellies using high sugar
concentration to preserve fruit.

Once your body actually starts to feel great, your cravings will naturally
subside and you’ll be reaping the advantages of decreasing the
sugar within your diet. Everybody needs some tips once and even though,
however when your wellbeing is a risk then the stakes go higher.
Make jam and jellies using high sugar concentration to preserve fruit.