Dual Digit 7 Segment Display

Hardware

Dual Digit 7 Segment Display

LED Bright BD-A405ND Dual Digit 7 Segment Display

Has 16 pins 8 above and 8 below the display.

Pin 1 is in the bottom left hand corner, pins are numbered anti-clockwise to 16 in the top left hand corner (picture to follow).

Pins 4 and 5 power the display, these are linked to vout on  the mbed.

Left Digit

Pins connected as follows

p7----------------LED Pin 1

p8----------------LED Pin 2

p9----------------LED Pin 3

p10--------------LED Pin 16

p11--------------LED Pin15

p12--------------LED Pin14

p13--------------LED Pin13

Right Digit

Pins connected as follows

p14--------------LED Pin 8

p15--------------LED Pin 7

p16--------------LED Pin 6

p17--------------LED Pin 9

p18--------------LED Pin 10

p19--------------LED Pin 11

p20--------------LED Pin 12

 

Set a pin to 0 to light it, 1 to clear it.

I've deliberately made sure that pins 14 to 20 light up the same segments on the right digit as the left in order to be able to reuse the same array of arrays to calculate how to show the digit.

To count down from 99 to 00 on the display at one digit per second:

/**************************************************************************
***************************************************************************

Countdown from 99 to 0 on a dual digit 7 segment display
by Amos 12/10/2010 (that's October 12th!) 


***************************************************************************
***************************************************************************/

#include "mbed.h"

DigitalOut myLeftPins[] = {p7, p8, p9, p10, p11, p12, p13};
DigitalOut myRightPins[] = {p14, p15, p16, p17, p18, p19, p20};

/*
Individual numerals
int zero[] = {0, 0, 0, 1, 0, 0, 0};
int one[] = {0, 1, 1, 1, 1, 1, 0};
int two[] = {1, 0, 0, 0, 0, 1, 0};
int three[] = {0, 1, 0, 0, 0, 1, 0};
int four[] = {0, 1, 1, 0, 1, 0, 0};
int five[] = {0, 1, 0, 0, 0, 0, 1};
int six[] = {0, 0, 0, 0, 0, 0, 1};
int seven[] = {0, 1, 1, 1, 0, 1, 0};
int eight[] = {0, 0, 0, 0, 0, 0, 0};
int nine[] = {0, 1, 0, 0, 0, 0, 0};
*/

//This is an array of arrays where the first index into the array
//locates the pin combination which displays that digit
//eg numb[1] returns the array containg the segments to display 1.
int numb[10][7] = {{0, 0, 0, 1, 0, 0, 0},
                {0, 1, 1, 1, 1, 1, 0}, 
                {1, 0, 0, 0, 0, 1, 0}, 
                {0, 1, 0, 0, 0, 1, 0}, 
                {0, 1, 1, 0, 1, 0, 0}, 
                {0, 1, 0, 0, 0, 0, 1}, 
                {0, 0, 0, 0, 0, 0, 1}, 
                {0, 1, 1, 1, 0, 1, 0}, 
                {0, 0, 0, 0, 0, 0, 0}, 
                {0, 1, 0, 0, 0, 0, 0}};

int main()
{
    while(1)
    {
        for(int i = 0; i < 7; i++)
        {
            //clear all pins
            myLeftPins[i] = 1;
            myRightPins[i] = 1;
        }        
        //Countdown loop
        for(int x = 99; x >= 0; x--)
        {
            //set the main counter
            for(int i = 0; i < 7; i++)
            {
                //Left digit displays the value of x/10 ie the tens column
                myLeftPins[i] = numb[x/10][i]; 
                //Right digit displays the value of x%10 ie the units column
                myRightPins[i] = numb[x%10][i];         
            }
            //1 second
            wait(1);
        }
    }
}

Countdown Display

A picture of the countdown clock.

Download this code here:

myflashy

The countdown is at least as accurate time-wise as the stop watch on my (analogue) wrist-watch.

Things I might do with this now:

Add some buttons to start/stop/pause/set the countdown.

Make a counter upper (pushing a button adds one to the count).

Add a speaker/buzzer to sound an alarm when the count down is done.


7 comments

12 Oct 2010

I'm suprised it took this long for someone to publish something with 7-segment displays.. I guess LCD displays ruined us :P

12 Oct 2010

Uh, the love of the integrated controller IC's...
Then we won't have to multiplex, and we can do loads of other tasks instead. :-)

Lerche

12 Oct 2010 . Edited: 12 Oct 2010

I got an mbed at the weekend and was looking for something to get me started playing with it. In my scrap box was this dual digit 7 segment display (from a cd player I think). I think I'll try and make a simple countdown timer that'll do up to 100 seconds. With buttons to set the start time etc. This is just my first few baby steps.

28 May 2013

Hi how would you guys connect 3 single seven segment displays with 10 pins each to mbed? This is the display.

Sorry for the question since i am a newbie. Thanks

30 May 2013

You can connect all the a's, b's etc... together and connect driver fets to the annode/cathode of each indavidual display. If you need them all on at once you will need to strobe the display by swiching them quickly.

09 Jan 2015
Hi! i have same chip as u do however i have to use arduino uno, i only have ports 2-9?
09 Jan 2018
thankyou

You need to log in to post a comment