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

Arduino LED Bar Graph with a 4017 Counter

(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.

Arduino LED Bar graph driven by a 4017 counter

(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);
}

Click here to download the source (arduino_led_bar_graph_4017.pde / 1KB)

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!

Leave a comment ?

14 Comments.

  1. Thank you for this! It was very helpful to me, as a rank Arduino beginner. Might you someday do a similar tutorial showing the use of shift-registers? Please?

  2. 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)?

    • It’s ok, I forgot to put a resistor between the 3rd/Rst pin.
      About my question, you have to match IC’s pinout sequence.

  3. I must project to produce 10 Leds(many colours)with 555Timer and 4017Counter.I must try to do.

  4. 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

  5. Was able to reproduce it using 10 LED.

  6. You need a resistor on the LEDs to limit the current. The 5v output of the arduino is too high and will burn out the LEDs without a current limiting resistor.

    • 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.

  7. straight from the source
    It’s amazing in support of me to have a site, which is valuable
    in support of my know-how. thanks admin https://www.goodreads.com/user/show/77421847-morgan

  8. The Arduino is only serving to provide a clock signal. It does nothing more. Why not omit the 4017 chip and program 10 Arduino pins to count to 1024? It would be much cooler.

  9. Check out this website for a 4-bit counter. Easy to take it up to 10-bit counter.

    http://www.instructables.com/id/Arduino-Insight-LEDS/

  10. 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.

  11. 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.

Leave a Comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.