INCLUDE "modedefs.bas" DEFINE osc 4 output PORTB.0 '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 arrayCol var byte[8] arrayRow var byte[8] '============ Initialization of program happens here ============' ALL_ON = $FF ALL_OFF = $00 pauseDuration = 10 arrayCol[0] = %00000000 ' All ON arrayCol[1] = %10000000 arrayCol[2] = %11000000 arrayCol[3] = %11100000 arrayCol[4] = %11110000 arrayCol[5] = %11111000 arrayCol[6] = %11111100 arrayCol[7] = %11111110 arrayCol[8] = %11111111 ' ALL OFF arrayRow [0] = 0 arrayRow [1] = 1 arrayRow [2] = 2 arrayRow [3] = 3 arrayRow [4] = 4 arrayRow [5] = 5 arrayRow [6] = 6 arrayRow [7] = 7 '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, [%0000101100000011\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 'turn them all off, so that we start off clean For i = 0 To 7 low IOPIN SHIFTOUT DPIN, CPIN, 1, [i+1, ALL_OFF] high IOPIN Next i 'disable shutdown mode xxxx1100xxxxxxx1 (shutdown mode xxxx1100xxxxxxx0) low IOPIN SHIFTOUT DPIN, CPIN, 1, [%0000110000000001\16] high IOPIN pause 10 '================================================================' main: For i = 0 To 7 low IOPIN SHIFTOUT DPIN, CPIN, 1, [i+1, arrayCol[i]] pause 75 high IOPIN Next i pause 250 low IOPIN SHIFTOUT DPIN, CPIN, 1, [tempRow, ALL_OFF] high IOPIN pause 250 GoTo main 'this is the subroutine that gets called each time to shift out the values shiftIt low IOPIN SHIFTOUT DPIN, CPIN, 1, [tempRow, tempCol] pause pauseDuration high IOPIN Return