'**************************************************************** '* Name : UNTITLED.BAS * '* Author : schaum * '* Notice : Copyright (c) 2006 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 3/14/2006 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** 'This code lights up individual discrete LED's and scans through a 5x5 LED grid using a Maxim 7219. DEFINE osc 4 output PORTC.3 output PORTD.3 output PORTD.1 'define DataPin, ClockPin, Load Pin D0PIN var PORTC.3 CPIN var PORTD.3 IOPIN var PORTD.1 '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 j var byte random j ' 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] arrayCol 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 arrayCol[0] = %10000000 ' All OFF arrayCol[1] = %01000000 arrayCol[2] = %00100000 arrayCol[3] = %00010000 arrayCol[4] = %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 D0PIN, CPIN, 1, [%0000101100000100\16] high IOPIN PAUSE 10 'set the intensity register, initially lights are at full intensity. low IOPIN SHIFTOUT D0PIN, CPIN, 1, [%0000101000001111\16] high IOPIN PAUSE 10 'disable shutdown mode xxxx1100xxxxxxx1 (shutdown mode xxxx1100xxxxxxx0) low IOPIN SHIFTOUT D0PIN, CPIN, 1, [%0000110000000001\16] high IOPIN PAUSE 10 'disable display mode xxxx1111xxxxxxx0 (display mode xxxx1100xxxxxxx1) low IOPIN SHIFTOUT D0PIN, 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 D0PIN, CPIN, 1, [arrayRow[i], ALL_OFF] high IOPIN Next i PAUSE 10 main: 'scan the rows 0,1,2,3,4,5 by putting them on for i = 0 to 5 for j = 0 to 5 low IOPIN SHIFTOUT D0PIN, CPIN, 1, [arrayRow[i], arrayCol[j]] high IOPIN PAUSE 500 next j pause 500 next i low IOPIN SHIFTOUT D0PIN, CPIN, 1, [arrayRow[i], All_OFF] high IOPIN PAUSE 500 GoTo main