7 Segment LED help
TacNayn
Posts: 3
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.
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
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.
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.