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


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)


 * Simple LED Bar graph animation using a 4017 counter.
 * The 4017 is used to save pins on the arduino.
 * Developed by Leonel Machava
 * This code is release under the "MIT License" available at

/* PIN used to send clock pulses to the counter. */
int clockPin = 2;

void setup() {

 * Sends a clock pulse to the counter making it advance.
void clock() {

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 */
  /* Wait for 300 ms. */

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!

  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

  5. Was able to reproduce it using 10 LED.

Reply to Yaw Gyi ¬
Cancel reply

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