'This code does a row-column scan for 2, 5x5 LED grids using two Maxim 7219. DEFINE osc 4 output PORTB.0 output PORTC.3 output PORTC.4 'define DataPin, ClockPin, Load Pin DPIN var PORTC.4 CPIN var PORTC.3 IOPIN var PORTB.0 'pauseDuration var byte 'temp1 var byte 'variables to put the current row, current column tempRow var byte tempCol var byte 'variables for all on/ all of on a certain row ALL_ON var byte ALL_OFF var byte i var byte ' array to hold the columns, rows, threshold values, serial input arrayColP VAR BYTE ' All OFF arrayColA VAR BYTE arrayColB VAR BYTE arrayColC VAR BYTE arrayColD VAR BYTE arrayRow var byte[8] '============ Initialization of program happens here ============' ALL_ON = $FF ALL_OFF = $00 ' pauseDuration = 10 arrayColP = %10000000 ' All OFF arrayColA = %01000000 arrayColB = %00100000 arrayColC = %00010000 arrayColD = %00001000 arrayRow [0] = %00000001 arrayRow [1] = %00000010 arrayRow [2] = %00000011 arrayRow [3] = %00000100 arrayRow [4] = %00000101 'XXXXAAAA 00000000 high IOPIN 'set chip select line high PAUSE 10 'first worry about decode mode. on power up device does not decode 'so we do not need to do anything ' set the scan limit to xxxx1011xxxxxxxx (display Digit0,1,2,3,4,5,6,7 xxxxx111) low IOPIN SHIFTOUT DPIN, CPIN, 1, [%0000101100000100\16] high IOPIN PAUSE 10 'set the intensity register, initially lights are at full intensity. low IOPIN SHIFTOUT DPIN, CPIN, 1, [%0000101000001111\16] high IOPIN PAUSE 10 'disable shutdown mode xxxx1100xxxxxxx1 (shutdown mode xxxx1100xxxxxxx0) low IOPIN SHIFTOUT DPIN, CPIN, 1, [%0000110000000001\16] high IOPIN PAUSE 10 'disable display mode xxxx1111xxxxxxx0 (display mode xxxx1100xxxxxxx1) low IOPIN SHIFTOUT DPIN, CPIN, 1, [%0000111100000000\16] high IOPIN PAUSE 10 'turn them all off, so that we start off clean For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[i], ALL_OFF] SHIFTOUT DPIN, CPIN, 1, [arrayRow[i], ALL_OFF] high IOPIN Next i PAUSE 500 main: 'scan the rows 0,1,2,3,4,5 by putting them on For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], ALL_ON] SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], ALL_ON] high IOPIN PAUSE 500 Next i 'put the rows one by one For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[i], ALL_OFF] SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], ALL_Off] high IOPIN Next i PAUSE 500 ' put the decimal point segment ON on all the digits for the coloumn scan For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColP] SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColP] high IOPIN Next i PAUSE 500 ' put the 'A' segment ON on all the digits for the coloumn scan For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColA] SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColA] high IOPIN Next i PAUSE 500 ' put the 'B' segment ON on all the digits for the coloumn scan For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColB] SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColB] high IOPIN Next i PAUSE 500 ' put the 'C' segment ON on all the digits for the coloumn scan For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColC] SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColC] high IOPIN Next i PAUSE 500 ' put the 'D' segment ON on all the digits for the coloumn scan For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColD] SHIFTOUT DPIN, CPIN, 1, [arrayRow[I], arrayColD] high IOPIN Next i PAUSE 500 'turn all the LED's off For i = 0 To 4 low IOPIN SHIFTOUT DPIN, CPIN, 1, [arrayRow[i], ALL_OFF] SHIFTOUT DPIN, CPIN, 1, [arrayRow[i], ALL_OFF] high IOPIN Next i GoTo main