Shop OBEX P1 Docs P2 Docs Learn Events
SparkFun Serial 7-Segment Serial Display — Parallax Forums

SparkFun Serial 7-Segment Serial Display

Ron CzapalaRon Czapala Posts: 2,418
edited 2011-12-09 18:55 in General Discussion
I just got a couple of these four digit, 7-segment LED display modules from SparkFun.

They can be driven by TTL Serial or SPI and come in several colors.

I am using a BS2 at 9600 baud in the video. The characters look whitish in the video, but are actually bright blue. There are commands to set the brightness, change the baud rate and control individual segments and decimal points/colon.

I am really pleased with them!

Comments

  • w4fejw4fej Posts: 264
    edited 2011-03-27 08:06
    You get 5 stars for entertainment value alone!! PERFECT music for the video!!

    Well done!

    Mike B.
  • kwinnkwinn Posts: 8,697
    edited 2011-03-27 10:59
    Have to agree with w4fej. 5 stars from me as well.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-03-27 18:56
    Thanks w4fej & kwinn!

    I didn't record any audio so I used the YouTube AudioSwap feature and stumbled on this background music - I don't even recall the name, but it does almost appear like it is synched to the display's "animation"...
  • CalMarinerCalMariner Posts: 64
    edited 2011-12-09 17:17
    Is there any demo code for this?
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-12-09 18:04
    Here is the Basic Stamp code I used in the video - pretty straightforward...
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DecPts      CON    $77   ' "w" Decimal point command
    Brightness  CON    $7A   ' "z" Brightness command 0(bright) - 254(dim)
    setBaud     CON    $7F   ' DEL 0=2400, 1=4800, 2=9600, 3=1440, 4=19200, 5=38400, 6=57600
    ClearScr    CON    $76   ' "v" clear display and set position to 1st digit
    Digit1      CON    $7B   ' "{" set individual segments for digit one
    Digit2      CON    $7C   ' "|" set individual segments for digit two
    Digit3      CON    $7D   ' "}" set individual segments for digit three
    Digit4      CON    $7E   ' "~" set individual segments for digit four
    #SELECT $STAMP                          ' Select Baud constants
      #CASE BS2, BS2E, BS2PE
        T1200       CON     813
        T2400       CON     396
        T4800       CON     188
        T9600       CON     84
        T19K2       CON     32
      #CASE BS2SX, BS2P
        T1200       CON     2063
        T2400       CON     1021
        T4800       CON     500
        T9600       CON     240
        T19K2       CON     110
      #CASE BS2PX
        T1200       CON     3313
        T2400       CON     1646
        T4800       CON     813
        T9600       CON     396
        T19K2       CON     188
    #ENDSELECT
    Inverted        CON     $4000           'Value for inverted serial format
    Baud            CON     T9600      '+ Inverted 8,N,1 inverted
    LED7 CON 0
    'msg DATA "0123456789AbCcDEeFGHhIJLnOoPqrStUuy-'_"
    msg DATA "    Scroll test - ABCDEF_0123456789    "
    msgend DATA 0
    msglen  VAR Byte
    msgAddr VAR Word
    disp VAR Byte(4)
    i    VAR Byte
    j    VAR Byte
    k    VAR Byte
    patt VAR Byte
    nxt  VAR Byte
    Main:
      msglen = msgend - msg    'calc length of data string
    '  DEBUG CLS
      SEROUT LED7,Baud,[ClearScr]
      PAUSE 100
      SEROUT LED7,Baud,[Brightness, 16]   '0]
      PAUSE 100
      patt = 0
      SEROUT LED7,Baud,[Decpts, patt]
    DO
      SEROUT LED7,Baud,[ClearScr]
      FOR j= 0 TO 5
        GOSUB Chase
      NEXT
      GOSUB AllChars
      PAUSE 500
      FOR j = 0 TO 3
        GOSUB DecPoints
      NEXT
      PAUSE 500
    LOOP
    STOP
    AllChars:
      msgAddr = msg              'set to start of scroll string
      k = 0
      DO
        FOR i = 0 TO 3
          READ k, nxt
          IF nxt = 0 THEN
            disp(i) = " "
          ELSE
            disp(i) = nxt
            k = k + 1
          ENDIF
        NEXT
        SEROUT LED7,Baud,[disp(0), disp(1), disp(2), disp(3)]
    '    DEBUG disp(0), disp(1), disp(2), disp(3), " ", DEC k, CR
        IF k >= msgend THEN
          EXIT
        ELSE
          k = k - 3
          PAUSE 200
        ENDIF
      LOOP
      RETURN
    Chase:
      patt = %00000001
      FOR i=0 TO 5
        SEROUT LED7,Baud,[Digit1, patt]
        SEROUT LED7,Baud,[Digit2, patt]
        SEROUT LED7,Baud,[Digit3, patt]
        SEROUT LED7,Baud,[Digit4, patt]
        patt = patt << 1
        PAUSE 80
      NEXT
      RETURN
    DecPoints:
      SEROUT LED7,Baud,[Digit1, %01001001]
      SEROUT LED7,Baud,[Digit2, %01000110]
      SEROUT LED7,Baud,[Digit3, %01110000]
      SEROUT LED7,Baud,[Digit4, %01100100]
      patt = %00000001
      FOR i=0 TO 6
        SEROUT LED7,Baud,[Decpts, patt]
    '    SEROUT LED7,Baud,[Brightness, (i * 20)]
        patt = patt << 1
        PAUSE 150
      NEXT
      RETURN
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-12-09 18:55
    I also like these displays. They're an easy way to add a numeric display to a project.

    I modified the object that comes with the Parallax Laser Range Finder to take continuous readings and display the distance (in mm) to the display.

    Here's the modified display method:
    PRI LRFDisplayRange(range, type)      ' Print the range result
      {
      if (type == cam#ResultBinary)  ' Send 4-byte long in binary corresponding to the actual range value
        ser.Tx(range.BYTE[3])
        ser.Tx(range.BYTE[2])
        ser.Tx(range.BYTE[1])
        ser.Tx(range.BYTE[0])
      else  }                         ' Default to printable ASCII output
        'ser.Tx(NL)
        'ser.Str(String("D = "))
      [B]  if range <> oldRange
          ser.Tx("v")
          ser.Tx("0" + range / 1000)                ' Add leading zeros so we always send a 4-character value
          ser.Tx("0" + (range // 1000) / 100)
          ser.Tx("0" + (range // 100)  / 10)
          ser.Tx("0" + (range // 10))
    [/B]   'ser.Str(String(" mm "))
          [B]oldRange := range
    [/B]
    

    I had make a couple other modifications to the code. I'm attaching the modified archive.
Sign In or Register to comment.