Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!

sevenseg01.gif

I’ve been playing around with the 7-Segment Shield for Arduino from the Maker Shed, and realize that I need a better understanding of how seven segment displays work.

When addressing the display from the sample Arduino sketch, I was pulling pre-formed characters from an array of hex values.This means that when I wanted a number 3, for example, I’d ask for NumberLookup[3], which had been assigned hex value 0x4F. I asked my friend Tod Kurt, “What’s this mapping, is there a standard table of characters to hex they’re pulling from?”. He responded, “That’s hex for “01001111″ in binary, five ones in there equate to five lit segments. You should look at the datasheet for the SAA1064 LED-driver for the segment mapping. Or better yet, reverse-engineer the binary-to-segment relationship.”

sevenSegNotebookScan01.jpg

So that’s what I did, and I have a better understanding of how it works as a result. Starting with the decimal point and moving through each character segment, I numbered which segment lit up when I asked for them to display via binary. The first place, or B10000000, lit the dot. Next, B01000000, lit the middle horizontal segment. Once I’d mapped out all the relationships, I wrote an Arduino sketch to cycle through each segment on the first digit, while displaying its binary place in the third digit (that’s the fancy GIF animation up there). Next up, I’ll discuss forming characters from an array of hex values.

In the Maker Shed
MKGR2-3.jpg

The Arduino 7-Segment Shield has four 7-segment displays (and driver), a temperature sensor, a PWM RGB LED, and plugs into an Arduino.


Related

Comments

  1. Nate says:

    Your approach is totally right, John, and you’re getting the correct results.

    However, you’ve mislabeled your byte value — what you’re calling the “first position” is technically the eighth. The digits count upward just as if you had 8 0s and were counting with decimal (00000000, 00000001…00000009, 00000010, etc.).

    Also (and this is through no fault of your own), the map of the digit doesn’t match a standard 7-segment display. I’m guessing that it’s because of the shield you’re using as opposed to the display itself. http://gavinblack.blogspot.com/1990/02/dual-display-pinout.html That should be what the display itself should look like.

    Overall, though, this is a great explanation of what’s going on with the display. Keep it up!

    1. John Park says:

      Nate, thanks for the clarification, I appreciate it. “Sort of backwards” neatly sums me up half the time!

      So you’re saying I ought to have labeled the “.” character as 8, middle horizontal as 7, etc, right? I’ll leave the post alone for historical record, but update my own notes.

      Here’s a link to the driver datasheet: http://www.grifo.com/PRESS/DOC/Philips/SAA1064.pdf

      Thanks again.

      1. Nate says:

        You got it, John.

        And, I was confusing pinout with the actual notation of the segments, too. Circuit Gizmo’s post below sums it up well.

        (in my own defense, my mind *has* to work with the pinout; I can’t convert from the a-b-c ordering into pin numbers on my uC.)

  2. CircuitGizmo says:

    A 7 seg display is most often labeled a-g.

    The top segment is ‘a’, upper right ‘b’, lower right ‘c’, bottom is ‘d’, lower left ‘e’, upper left ‘f’, and the center segment is ‘g’. The decimal point is ‘dp’.

    aaa
    f b
    f b
    ggg
    e c
    e c
    ddd dp

    You don’t “have to” wire it in any particular way, but the most common from my decades of embedded design experience is with ‘a’ as the LSB / bit 0. It’ll work in any order that you wish to decode, but for the sake of teaching, it might be best to follow the common.

    0 = abcdef
    1 = bc
    2 = abdeg
    3 = abcdg
    4 = bcfg
    5 = acdfg
    6 = acdefg
    7 = abc
    8 = abcdefg
    9 = abcdfg
    A = abcefg
    b = cdefg
    C = adef
    d = bcdeg
    E = adefg
    F = aefg

  3. CircuitGizmo says:

    _aaa_
    f___b
    f___b
    _ggg_
    e___c
    e___c
    _ddd_

  4. I like to know how to set 7 segment with 8051 microcontroller when i press 1 the led will light up n 7 segment display 01 n ext…

  5. I like to know how to set 7 segment with 8051 microcontroller when i press 1 the led will light up n 7 segment display 01 n ext…

In the Maker Shed