Shop OBEX P1 Docs P2 Docs Learn Events
7 Segment LED help — Parallax Forums

7 Segment LED help

TacNaynTacNayn Posts: 3
edited 2012-05-02 07:16 in BASIC Stamp
Hello, all.

So, I have this 2-digit 7-segment LED that I'm controlling with a max7219cng driver. But I have no idea how to program it.

If someone could help me out and provide a sample code, that would be great. Just any simple code that would make it display the number 05 or something. Thanks.

Comments

  • FranciscoTavaresFranciscoTavares Posts: 27
    edited 2012-04-27 10:47
    It uses a SPI interface but with one direction only. You can look at my post "ISD1700 Voice Recorder"
    There you will find how to send information using this interface.
    I´ll try to create a small subrotine, but I don´t have this chip and so I'll not be able to test the sw.
    TacNayn wrote: »
    Hello, all.

    So, I have this 2-digit 7-segment LED that I'm controlling with a max7219cng driver. But I have no idea how to program it.

    If someone could help me out and provide a sample code, that would be great. Just any simple code that would make it display the number 05 or something. Thanks.
  • TacNaynTacNayn Posts: 3
    edited 2012-04-29 15:03
    So, I found this sample code online. I'm just having difficulty understanding it. Can anyone explain what each part is doing?
  • FranklinFranklin Posts: 4,747
    edited 2012-04-29 18:09
    What part of the code are you having trouble with? Ask specific questions please. Have you run the code you linked and what did it do?
  • TacNaynTacNayn Posts: 3
    edited 2012-05-01 05:23
    What specific part of the code controls which number is displayed and what should I change to change the number?
  • FranciscoTavaresFranciscoTavares Posts: 27
    edited 2012-05-02 07:16
    Write_Display:
    FOR i = tempByte TO 4
    LOW LOADPIN
    SHIFTOUT DINPIN, CLKPIN, MSBFIRST, [(MAX7219_LeftDigit - i)\8 , (tempWord DIG (4-i))\8]
    HIGH LOADPIN ' For DIG operator, 0 = rightmost, 4 = left
    NEXT


    RETURN




    (MAX7219_LeftDigit - i)\8 selects the digits that will display one number
    It starts with digit 4. See "Table 2. Register Address Map" in the MAX7219 data sheet.
    MAX7219_LeftDigit=CON $05 which is digit number 4 code.


    tempWord DIG (4-i))\8 gives the number that will be displayed (first on digit 4)
    tempWord=56123 with i=0, DIG will select digit number 0 first, which in this case is 3.


    Then i changes to 1. display number 3 is chosed and number 2 is showed on that digit.


    So basically after chip initialization you need just these 3 comands:
    LOW LOADPIN
    SHIFTOUT DINPIN, CLKPIN, MSBFIRST, DigitCode\8 , Number\8]
    HIGH LOADPIN


    Where DigitCode is the code of the desired digit in your project and Number is the number you want to show on that digit.
    Both variables are bytes ones.


    TacNayn wrote: »
    So, I found this sample code online. I'm just having difficulty understanding it. Can anyone explain what each part is doing?
Sign In or Register to comment.