Driving a 7-segments LED display with Arduino and a DC4511

My experiments with the Arduino platform continue with a small 7-segments common cathode LED display and a cheap IC (Integrated Circuit) CD4511.

This IC is basically a BCD (Binary Coded Decimal) to 7-segments driver, you feed it with a 4-bit array and it lights up corresponding segments on the display, additional pins on the IC allow you to switch on and off all leds and to “freeze” (store) the display.

The advantage of using the 4511 is that you can consume just 4 arduino pins instead of the 7 that you would need when controlling the individual display segments one-by-one (set aside the decimal point, which would count to 8).

Note that the 4511 has 7 outputs only, this means that you cannot use it to control the DP (Decimal Point)  rounded led in the display.

I’m using firmata and pyfirmata (see my previous article about firmata: http://www.itopen.it/2012/02/21/arduino-pyfirmata-ldr-semaphore/ )  because I wanted to interactively control what was going on issuing commands on my favourite python shell (http://ipython.org/) .

The code is quite self explanatory, the wiring is listed at the top (see also the picture attached to this article), this script basically counts up and down from 0 to 9 and blinks when reaches 0 and 9.

driving 7 segments led display with a CD4511 IC


    CD4511    Connection
    1   A1    arduino pin 9
    2   A2    arduino pin 10
    3   LT    arduino pin 3 (lamp test)
    4   BL    arduino pin 2 (blink)
    5   LE    GND
    6   A3    arduino pin 11
    7   A7    arduino pin 8
    8   GND   GND
    9   e     \
    10  d     |     AA
    11  c     |    F  B
    12  b      >    GG
    13  a     |    E  C
    14  g     |     DD
    15  f     /
    16  +5V   +5V

import time
from pyfirmata import Arduino, util
board = Arduino('/dev/ttyACM0')

# Assign data pins
pins = [board.get_pin('d:'+str(i)+':o') for i in [8, 9, 10, 11]]
# BLank pin
bl = board.get_pin('d:2:o')
# Light Test pin
lt = board.get_pin('d:3:o')

def blink():
    """Blink active leds"""
    print "blinking..."
    for i in range(1, 4):

def show_digit(num):
    """Shows a digit on the display"""
    print "showing digit %s" % num
    for p in range(0, 4):
        pins[p].write(num % 2)
        num /= 2

# Test lamp
print "Testing lamp..."
print "...done"
print "start counting..."

cycle = 0
while cycle > 100:
    for d in range(0, 10):
    for d in range(9, -1, -1):
It's only fair to share...Tweet about this on TwitterShare on FacebookShare on LinkedInPin on PinterestShare on RedditShare on Google+

2 Responses to “Driving a 7-segments display with arduino CD4511 and pyfirmata”