Here is how I have done it with an 8x8 led matrix.
using a 16f690 or 16f1829
the three pertinant code snippets below are from that program.
you may want to copy / paste them into microcode studio or, even better, use FineLine IDE which also shows lines on for/next loops and makes it easier to follow the code.
I can send you the whole program and schematic if it would be helpful.
works very well.
There has been over 400 kits built using this code.
Code:arraywrite msg,["High Uintah 2015"] len=16:GOSUB Message arraywrite msg,["A Scout is..."] len=13:GOSUB Message arraywrite msg,["Trustworthy"] len=11:GOSUB Message arraywrite msg,["Loyal"] len=5:GOSUB Message arraywrite msg,["Helpful"] len=7:GOSUB Message arraywrite msg,["Friendly"] len=8:GOSUB Message arraywrite msg,["Courteous"] len=9:GOSUB Message arraywrite msg,["Kind"] len=4:GOSUB Message arraywrite msg,["Obedient"] len=8:GOSUB Message arraywrite msg,["Cheerful"] len=8:GOSUB Message arraywrite msg,["Thrifty"] len=7:GOSUB Message arraywrite msg,["Brave"] len=5:GOSUB Message arraywrite msg,["Clean"] len=5:GOSUB Message arraywrite msg,["Reverent"] len=8:GOSUB MessageCode:'========================================================================== ' MESSAGE subroutine '========================================================================== Message: now=0 FOR ltr=0 TO len-1 char=msg[ltr] pos = 0 'reset pos counter for new letter GOSUB GetChar 'get first value representing number of columns pix=col 'set pix to be number of columns in current character FOR pos = 1 TO pix 'pos starts at 1 to skip first character data GOSUB GetChar 'get actual character data x88[now]=col 'store character data in current position of matrix GOSUB Display 'display each new character column data NEXT pos x88[now]=$FF 'follow each character with 2 blank spaces GOSUB Display x88[now]=$FF GOSUB Display NEXT ltr Finish: 'follow each word with 2 complete blank screens FOR ltr = 1 TO 16 x88[now]=$ff GOSUB Display NEXT ltr RETURNCode:'========================================================== ' DISPLAY subroutine '========================================================== Display: 'display the current 8x8 matrix "view" times IF col=0 THEN 'check to see if should scroll or static now=0 GOTO DntScrl 'skip incrementing now (which causes scrolling) ENDIF now=now+1 'increment position counter for scrolling IF now=8 THEN now=0 'done with frame so reset postion DntScrl: FOR view = 0 TO speed 'scroll speed, number of time to scan each screen IF BtnTmr = 0 THEN GOSUB Btn 'time to check for button press BtnTmr=BtnTmr -1 'else decriment BtnTmr for button debounce FOR r = 0 TO 7 'count for row scanning 'The following lookup is used to creat a "walking" 1 'for Row Scanning. Row port pins are not contiguous. 'The list of numbers is dependant on which PIC pins 'are connected to which LED matrix rows. In this case 'pins A.0:A.1:A.2:A.5:B.4:B.5:B.6:B.7 '(A.5 and B.5 cause 32 to be used twice.) LOOKUP r, [1,2,4,32,16,32,64,128], row 'walking "1" for row scanning IF r<4 THEN PortA=row 'PortA 0,1,2,5 is connected to row 1-4 ELSE PortB=row 'PortB 4,5,6,7 is connected to row 5-8 ENDIF i=r + now 'combine row count with position counter(now) IF i>7 THEN i=i-8 'to create scrolling effect col=x88[i] IF r=0 THEN 'this is the Car row so combine track with car crash=col |/ car ' check for collision using NOR function col=col & car ' show car postion ENDIF IF crash >0 THEN 'crashed wface=11 'so set up for crash indicator GOTO Crashed 'then goto display crash symbol ENDIF PortC=col 'set the column LED's with current col PAUSEUS LOn 'on time for each col (250,500,1000,1500) PortA=0 :PortB=0 'all rows off PortC=%11111111 'all cols off NEXT r NEXT view RETURNCode:GetChar: SELECT CASE char case" " :LOOKUP pos, [2,$FF,$FF], col Case"!" :LOOKUP pos, [1,$05], col Case"*" :LOOKUP pos, [9,$FF,$BF,$5F,$BF,$FF,$01,$6F,$6F,$7F], col 'deg F Case"+" :LOOKUP pos, [7,$FF,$FF,$EF,$EF,$83,$EF,$EF], col Case"-" :LOOKUP pos, [6,$FF,$FF,$EF,$EF,$EF,$EF], col Case"." :LOOKUP pos, [2,$F9,$F9], col Case"0" :LOOKUP pos, [5,$83,$75,$6D,$5D,$83], col Case"1" :LOOKUP pos, [3,$BD,$01,$FD], col Case"2" :LOOKUP pos, [5,$BD,$79,$75,$6D,$9D], col Case"3" :LOOKUP pos, [5,$7B,$7D,$6D,$4D,$33], col Case"4" :LOOKUP pos, [5,$E7,$D7,$B7,$01,$F7], col Case"5" :LOOKUP pos, [5,$1B,$5D,$5D,$5D,$63], col Case"6" :LOOKUP pos, [5,$C3,$AD,$6D,$6D,$F3], col Case"7" :LOOKUP pos, [5,$7F,$71,$6F,$5F,$3F], col Case"8" :LOOKUP pos, [5,$93,$6D,$6D,$6D,$93], col Case"9" :LOOKUP pos, [5,$9F,$6D,$6D,$6B,$87], col Case"A" :LOOKUP pos, [5,$C1,$B7,$77,$B7,$C1], col Case"B" :LOOKUP pos, [5,$7D,$01,$6D,$6D,$93], col Case"C" :LOOKUP pos, [5,$83,$7D,$7D,$7D,$BB], col Case"D" :LOOKUP pos, [5,$7D,$01,$7D,$7D,$83], col Case"E" :LOOKUP pos, [5,$01,$6D,$6D,$6D,$7D], col Case"F" :LOOKUP pos, [5,$01,$6F,$6F,$6F,$7F], col Case"G" :LOOKUP pos, [5,$83,$7D,$7D,$6D,$61], col Case"H" :LOOKUP pos, [5,$01,$EF,$EF,$EF,$01], col Case"I" :LOOKUP pos, [3,$7D,$01,$7D], col Case"J" :LOOKUP pos, [5,$FB,$FD,$FD,$FD,$03], col Case"K" :LOOKUP pos, [5,$01,$EF,$D7,$BB,$7D], col Case"L" :LOOKUP pos, [5,$01,$FD,$FD,$FD,$FD], col Case"M" :LOOKUP pos, [5,$01,$BF,$CF,$BF,$01], col Case"N" :LOOKUP pos, [5,$01,$DF,$EF,$F7,$01], col Case"O" :LOOKUP pos, [5,$83,$7D,$7D,$7D,$83], col Case"P" :LOOKUP pos, [5,$01,$6F,$6F,$6F,$9F], col Case"Q" :LOOKUP pos, [5,$83,$7D,$75,$7B,$85], col Case"R" :LOOKUP pos, [5,$01,$6F,$67,$6B,$9D], col Case"S" :LOOKUP pos, [5,$9B,$6D,$6D,$6D,$B3], col Case"T" :LOOKUP pos, [5,$7F,$7F,$01,$7F,$7F], col Case"U" :LOOKUP pos, [5,$03,$FD,$FD,$FD,$03], col Case"V" :LOOKUP pos, [5,$1F,$E7,$F9,$E7,$1F], col Case"W" :LOOKUP pos, [5,$03,$FD,$E3,$FD,$03], col Case"X" :LOOKUP pos, [5,$39,$D7,$EF,$D7,$39], col Case"Y" :LOOKUP pos, [5,$3F,$DF,$E1,$DF,$3F], col Case"Z" :LOOKUP pos, [5,$79,$75,$6D,$5D,$3D], col Case"a" :LOOKUP pos, [5,$E3,$DD,$DD,$EB,$C1], col Case"b" :LOOKUP pos, [5,$01,$ED,$ED,$ED,$F3], col Case"c" :LOOKUP pos, [5,$E3,$DD,$DD,$DD,$ff], col 'last col was $EB Case"d" :LOOKUP pos, [5,$E3,$DD,$DD,$DD,$01], col Case"e" :LOOKUP pos, [5,$E3,$D5,$D5,$D5,$E5], col Case"f" :LOOKUP pos, [5,$EF,$81,$6F,$6F,$BF], col Case"g" :LOOKUP pos, [5,$E7,$DA,$DA,$EA,$C0], col Case"h" :LOOKUP pos, [5,$01,$DF,$DF,$DF,$E1], col Case"i" :LOOKUP pos, [1,$41], col Case"j" :LOOKUP pos, [3,$F9,$FE,$41], col Case"k" :LOOKUP pos, [4,$01,$F7,$EB,$DD], col Case"l" :LOOKUP pos, [3,$03,$FD,$FD], col Case"m" :LOOKUP pos, [5,$C1,$DF,$E1,$DF,$E1], col Case"n" :LOOKUP pos, [5,$C1,$EF,$DF,$DF,$E1], col Case"o" :LOOKUP pos, [5,$E3,$DD,$DD,$DD,$E3], col Case"p" :LOOKUP pos, [5,$C0,$EB,$DB,$DB,$E7], col Case"q" :LOOKUP pos, [5,$E7,$DB,$DB,$C0,$FE], col Case"r" :LOOKUP pos, [5,$C1,$EF,$DF,$DF,$EF], col Case"s" :LOOKUP pos, [5,$EF,$D5,$D5,$D5,$FB], col Case"t" :LOOKUP pos, [4,$DF,$03,$DD,$FB], col Case"u" :LOOKUP pos, [5,$C3,$FD,$FD,$FB,$C1], col Case"v" :LOOKUP pos, [5,$C7,$FB,$FD,$FB,$C7], col Case"w" :LOOKUP pos, [5,$C3,$FD,$C3,$FD,$C3], col Case"x" :LOOKUP pos, [5,$DD,$EB,$F7,$EB,$DD], col Case"y" :LOOKUP pos, [4,$C7,$FA,$FA,$C1], col Case"z" :LOOKUP pos, [5,$DD,$D9,$D5,$CD,$DD], col Case":" :LOOKUP pos, [2,$99,$99], col END SELECT RETURN
Bookmarks