Make: Projects

Drive a 7-Segment LED with an Arduino

Learn how to hook up and drive a 7-segment LED display using the Arduino. We will use the Arduino alone to display numbers and letters (a-f) on our LED display.

  • By
  • Time Required: 30 minutes.
  • Difficulty: Moderate
Drive a 7-Segment LED with an Arduino

Using the Arduino development platform you will learn how to display numbers and letters on a single 7-segment LED display. There are many ways to drive 7-segment displays, and this is a fairly simple method. However, using this method to drive even one LED 7-segment array “burns” (occupies) many of the digital I/O pins on your Arduino. In later projects, I’ll show you how to use a dedicated 7-segment LED driver.


Step #1:

Drive a 7-Segment LED with an Arduino
  • Gather up your gear:
  • Two 220-ohm resistors (close to that value is good enough)
  • 11 male-to-male jumper wires
  • 1 Breadboard
  • 1 Arduino Development Board

Step #2:

Drive a 7-Segment LED with an ArduinoDrive a 7-Segment LED with an ArduinoDrive a 7-Segment LED with an ArduinoDrive a 7-Segment LED with an Arduino
  • Wire up your segment. Use the Fritzing image as your guide.
  • A = 8, B = 9, C=2, D=3, E=4, F=5, G=6
  • The two middle pins (Pin 3 and Pin 8) on top and bottom go to Ground (or to the first leg of the 220 ohm resistor). These are our current-limiting resistors.

Step #3:

Drive a 7-Segment LED with an Arduino
  • Load the code and you're good to go:
  • Get the code from here:
  • If you copy and paste the code into your Arduino sketch, you will see that if everything is hooked up correctly, it will loop from A-F then 1 - 0. This is not the most interesting project. However it does lay the groundwork for displaying data on a 7-segment LED for your Arduino projects.
  • The approach we used to drive this one 7-segment LED took 8 of our digital l/O lines. This is quite a few lines to "burn" for this functionality. However in upcoming tutorials, I will post some more elegant ways to drive 7-segment displays than using 8 digital I/O lines.
  • In the code there are 15 functions that will display the letter or number represented by the function name on the LED display. For example, if you were to run seven(), this would display the number 7 on the display. If you write a Pin LOW, you are in fact turning on that LED. If you write a pin HIGH it is now turned off.
  • That's it! All you have to do now is to program it to display something useful for your project.


  • Solar Interested

    Thanks for this. I’m just starting out with my Arduino and had a common cathode 7 segment display so your code was just what I wanted to get started.

  • JI

    In order to multiple 7-segment LED… How can we do a dedicated 7-segment LED driver?

  • Bert

    I tried to verify the code and got errors… please confirm

  • Hi,

    I was also having trouble with this code. After a little bit I finally got it working and submited a pull request on GitHub but apparently they don’t accept requests very often.

    If you’re having trouble, feel free to try my version on


  • If you want to build it yourself and like to solder, LucidTronix has a DIY kit that makes the wiring easier:

  • Chris Stamelos

    the code is full of bugs pfff

  • Pingback: Drive a 7-Segment LED with an Arduino « Donaldpek's Blog()

  • frog

    Your Code on Github has a few mistakes in it… I posted a pull request…

  • David Goodrich

    I was looking for a good starting point for lighting up a similar LED that I had wanted to use on a project (with potentiometer, sound, and servo motor). The project turned out well, but I ended up scrapping this code and wanted to give a respectful warning to others that this code will need a little work, so be prepared.

    Firstly, it won’t compile as-is with the couple of typos it has.

    In my case, my LED uses HIGH to light up (as you might expect), so bear this in mind.

    From an efficiency standpoint also you may want to consider encapsulating some of the digitalWrite logic so that there are not as many lines of redundant code.

    I’d be curious to see what Mr. Frog (commenter below) had done. I ended up overdoing it a little with a way to pass the on/off codes as a string encoding, but this is a good talking point for any student learners.


    void light_all() { drawLEDfromArray( “11111111” ); }
    void clear_all() { drawLEDfromArray( “00000000” ); }
    void char_A() { drawLEDfromArray( “11101110” ); }

    void drawLEDfromArray( char bits[] ) {
    // this lights up LED segments 0..8 when the correspond ing array item is ‘1’
    for (int i=0; i < LED_segments ; i++)
    if (bits[i] == '1')
    else light_off(LED_Pins[i]);

  • Scott

    MAKE – Will you consider a tutorial on using an Arduino to drive a pair of “large” set of these LEDs? Those big displays as you know require 9-12V and can not be driven by microcontroller pins or a shift register (not even the tpic6b595).

    Arduino forums are littered with novices asking how to do this (and surprisingly no one’s published a web tutorial, just some YouTube videos showing a successful build).

  • Pingback: Arduino | Pearltrees()