30LEDマトリクス表示



ハード


OUT 1,2,3,4,7をHレベルに、OUT 5,6,8,9,10,11をLレベルにすると、LEDに電流が流れて点灯します。
OUT 7は基板上のLEDが接続されているので、出力側にし、OUT 10はI2Cのためにオープンドレインなので入力側にしてあります。
縦1列を高速で順番に点灯させていきます。
OUTコマンドの1 2 4 8 64 のHレベルと 16 32 128 256 512 1024 のLレベル で点灯パターンを作ります。
OUT 5,6 と OUT 7で順番が不連続になっていることに注意




ガーバーデータ
KiCADでプリント基板を設計しました。

FontMake.xlsx

エクセルで縦列1 2 4 8 64の合計を計算するシート

ソフト

OUTの数値 1,2,4,8,64 は、
OUTのピン 1,2,3,4,7に対応し
ピンを1つずつHレベルにします。

OUT 1968 は 16+32+128+256+512+1024
OUT 5,6,8,9,10,11のピンに対応し
まとめてHレベルに設定し、接続しているLEDに電流を流します
ここから、1,2,16,32,64,128,256 × 16 の値を引くと
対応するピンがLレベルになり、接続されているLEDから電流が流れ込みます

100 OUT 1+1968-PEEK(L)*16
110 OUT 2+1968-PEEK(L+1)*16
120 OUT 4+1968-PEEK(L+2)*16
130 OUT 8+1968-PEEK(L+3)*16
140 OUT 64+1968-PEEK(L+4)*16

メモリにPOKEで書き込み・PEEKで読み出すか、配列を使う。変数を5つ使う、数値で直接記述しても可。
ループさせることで、縦1列ずつパターンを点灯します。
高速で点滅しているので、少し暗いが縦6×横5のパターンが表示されます

10 'I LOVE YOU
20 VIDEO0
30 FOR I=1 TO 11:OUT I,0:NEXT
40 '1 2 8 16 32 64 = 123
50 A=#800
60 POKEA,0,65,123,65,0
70 POKEA+5,0,0,0,0,0
80 POKEA+10,123,64,64,64,64
90 POKEA+15,58,65,65,65,58
100 POKEA+20,27,48,96,48,27
110 POKEA+25,123,73,73,73,65
120 POKEA+30,0,0,0,0,0
130 POKEA+35,3,24,112,24,3
140 POKEA+40,58,65,65,65,58
150 POKEA+45,59,96,64,96,59
160 POKEA+50,0,0,0,0,0
170 POKEA+55,26,59,122,59,26
180 POKEA+60,0,0,0,0,0
190 FORK=0TO5:FOR J=0 TO 12
200 L=A+J*5:GSB@S
210 NEXT:NEXT
220 BEEP:VIDEO1:END
230 @S:CLT
240 @L:IFBTN()THENOUT0:VIDEO1:END
250 OUT 1+1968-PEEK(L)*16
260 OUT 2+1968-PEEK(L+1)*16
270 OUT 4+1968-PEEK(L+2)*16
280 OUT 8+1968-PEEK(L+3)*16
290 OUT 64+1968-PEEK(L+4)*16
300 IFTICK()>60:OUT0:WAIT15:RTN
310 GOTO@L

10 'DANCE
20 VIDEO0
30 FOR I=1 TO 11:OUT I,0:NEXT
40 '1 2 8 16 32 64 = 123
50 A=#800
60 POKEA,67,114,27,114,67
70 POKEA+5,74,98,59,18,115
80 POKEA+10,74,114,27,114,74
90 POKEA+15,115,18,59,98,74
100 POKEA+20,67,114,27,114,67
110 POKEA+25,88,40,58,104,24
120 POKEA+30,24,104,58,40,88
130 POKEA+35,88,40,58,104,24
140 POKEA+40,24,104,58,40,88
150 FORK=0TO7:FOR J=0 TO 7
160 L=A+J*5:GSB@S
170 NEXT:NEXT
180 BEEP:VIDEO1:END
190 @S:CLT
200 @L:IFBTN()THENOUT0:VIDEO1:END
210 OUT 1+1968-PEEK(L)*16
220 OUT 2+1968-PEEK(L+1)*16
230 OUT 4+1968-PEEK(L+2)*16
240 OUT 8+1968-PEEK(L+3)*16
250 OUT 64+1968-PEEK(L+4)*16
260 IFTICK()>30:OUT0:WAIT2:RTN
270 GOTO@L

10 'IchigoJam LOGO
20 VIDEO0
30 FOR I=1 TO 11:OUT I,0:NEXT
40 '1 2 8 16 32 64 = 123
50 A=#800
60 POKEA,0,0,0,0,0
70 POKEA+5,0,91,64,90,82
80 POKEA+10,82,64,91,72,88
90 POKEA+15,64,89,0,90,82
100 POKEA+20,122,0,90,82,90
110 POKEA+25,64,80,80,91,64
120 POKEA+30,90,82,90,80,66
130 POKEA+35,90,66,90,66,90
140 POKEA+40,0,0,0,0,0,0
145 POKEA+45,0,0,0,0,0,0
150 FORK=0TO2:FOR J=0 TO 44
160 L=A+J:GSB@S
170 NEXT:NEXT
180 BEEP:VIDEO1:END
190 @S:CLT
200 @L:IFBTN()THENOUT0:VIDEO1:END
210 OUT 1+1968-PEEK(L)*16
220 OUT 2+1968-PEEK(L+1)*16
230 OUT 4+1968-PEEK(L+2)*16
240 OUT 8+1968-PEEK(L+3)*16
250 OUT 64+1968-PEEK(L+4)*16
260 IFTICK()>15RTN
270 GOTO@L

10 'FONT01
20 VIDEO0
30 POKE#900,0,0,0,0,0
40 POKE#905,0,0,91,0,0
50 POKE#90A,0,3,0,3,0
60 POKE#90F,18,59,18,59,18
70 POKE#914,34,41,123,41,17
80 POKE#919,67,35,24,98,97
90 POKE#91E,50,73,89,34,80
100 POKE#923,0,0,19,11,0
110 POKE#928,0,58,99,65,0
120 POKE#92D,0,65,99,58,0
130 POKE#932,41,26,59,26,41
140 POKE#937,8,8,59,8,8
150 POKE#93C,0,0,88,56,0
160 POKE#941,8,8,8,8,8
170 POKE#946,0,0,48,48,0
180 POKE#94B,64,32,24,2,1
190 POKE#950,58,97,89,67,58
200 POKE#955,0,2,123,0,0
210 POKE#95A,66,97,113,89,74
220 POKE#95F,34,65,73,123,50
230 POKE#964,56,34,33,123,32
240 POKE#969,75,75,73,121,49
250 POKE#96E,58,73,73,73,48
260 POKE#973,3,1,113,25,11
270 POKE#978,50,73,73,73,50
280 POKE#97D,10,81,81,81,58
290 POKE#982,0,0,34,0,0
300 POKE#987,0,64,34,0,0
310 POKE#98C,24,58,99,65,0
320 POKE#991,34,34,34,34,34
330 POKE#996,0,65,99,58,24
340 POKE#99B,10,1,81,17,10
350 POKE#9A0,58,65,89,81,74
360 LRUN1

10 'FONT02
20 POKE#9A5,120,18,17,18,120
30 POKE#9AA,123,73,73,73,114
40 POKE#9AF,58,65,65,65,34
50 POKE#9B4,123,65,65,65,58
60 POKE#9B9,123,73,73,73,65
70 POKE#9BE,123,9,9,9,1
80 POKE#9C3,58,65,65,81,50
90 POKE#9C8,123,8,8,8,123
100 POKE#9CD,0,65,123,65,0
110 POKE#9D2,0,33,65,59,1
120 POKE#9D7,123,24,56,106,99
130 POKE#9DC,123,64,64,64,64
140 POKE#9E1,123,2,8,2,123
150 POKE#9E6,123,2,24,32,123
160 POKE#9EB,58,65,65,65,58
170 POKE#9F0,123,17,17,17,10
180 POKE#9F5,58,65,81,33,90
190 POKE#9FA,123,17,17,113,74
200 POKE#9FF,34,73,73,81,50
210 POKE#A04,1,1,123,1,1
220 POKE#A09,59,64,64,64,59
230 POKE#A0E,11,48,64,48,11
240 POKE#A13,59,64,58,64,59
250 POKE#A18,99,58,24,58,99
260 POKE#A1D,3,8,112,8,3
270 POKE#A22,97,81,89,73,67
280 POKE#A27,0,123,65,65,0
290 POKE#A2C,1,2,24,32,64
300 POKE#A31,0,65,65,123,0
310 POKE#A36,8,2,1,2,8
320 POKE#A3B,64,64,64,64,64
330 POKE#A40,0,1,3,10,0
340 LRUN2

10 'FONT03
20 POKE#A45,48,72,72,56,64
30 POKE#A4A,0,122,80,112,0
40 POKE#A4F,0,120,72,72,0
50 POKE#A54,0,112,80,122,0
60 POKE#A59,0,122,82,90,0
70 POKE#A5E,0,8,122,9,0
80 POKE#A63,0,90,82,122,0
90 POKE#A68,0,122,16,96,0
100 POKE#A6D,0,0,114,0,0
110 POKE#A72,0,64,114,0,0
120 POKE#A77,0,122,16,104,0
130 POKE#A7C,0,0,122,0,0
140 POKE#A81,112,16,112,16,96
150 POKE#A86,0,112,16,96,0
160 POKE#A8B,0,48,72,48,0
170 POKE#A90,0,120,40,56,0
180 POKE#A95,0,56,40,120,0
190 POKE#A9A,0,120,32,16,0
200 POKE#A9F,0,72,82,34,0
210 POKE#AA4,0,8,122,72,0
220 POKE#AA9,0,112,64,112,0
230 POKE#AAE,0,48,64,48,0
240 POKE#AB3,48,64,48,64,48
250 POKE#AB8,0,104,16,104,0
260 POKE#ABD,0,90,80,122,0
270 POKE#AC2,0,98,82,74,0
280 POKE#AC7,8,51,33,0,0
290 POKE#ACC,0,0,123,0,0
300 POKE#AD1,0,33,51,8,0
310 POKE#AD6,16,8,16,32,16
320 LC0,20:LRUN3

10 S="Hello! IchigoJamBASIC "
20 N=LEN(S)-1
30 FOR I=1 TO 11:OUT I,0:NEXT
40 A=#900
50 @LP:FORI=0TON
60 L=A+(PEEK(S+I)-32)*5:GSB@S
70 NEXT:GOTO@LP
80 @S:CLT:BEEP
90 @L:IFBTN()THENOUT0:VIDEO1:END
100 OUT 1+1968-PEEK(L)*16
110 OUT 2+1968-PEEK(L+1)*16
120 OUT 4+1968-PEEK(L+2)*16
130 OUT 8+1968-PEEK(L+3)*16
140 OUT 64+1968-PEEK(L+4)*16
150 IFTICK()>60:OUT0:WAIT5:RTN
160 GOTO@L

10 POKE#700,4,21,31,4,14,10,0,0
15 POKE#900,10,104,59,104,10
20 POKE#708,4,20,31,5,28,19,0,0
25 POKE#905,106,40,59,72,88
30 POKE#710,4,5,31,20,7,25,0,0
35 POKE#90A,88,72,59,40,106
40 POKE#718,5,6,12,22,9,17,0,0
45 POKE#90F,80,40,27,18,97
50 POKE#720,20,12,6,13,18,17,0,0
55 POKE#914,97,18,27,40,80
60 POKE#728,4,31,21,4,31,17,0,0
65 POKE#919,106,34,59,34,106
70 POKE#730,21,31,4,4,31,17,0,0
75 POKE#91E,99,34,59,34,99
80 POKE#738,10,10,4,4,14,21,0,0
85 POKE#923,64,35,120,35,64
90 POKE#740,10,10,4,4,31,4,0,0
95 POKE#928,32,35,120,35,32
100 POKE#748,10,10,4,21,14,4,0,0
105 POKE#92D,16,35,120,35,16
110 POKE#750,8,8,15,8,14,2,0,0
115 POKE#932,0,59,40,104,8
120 POKE#758,2,2,30,2,14,8,0,0
125 POKE#937,8,104,40,59,0
130 LRUNFILE()+1

10 S=""
20 N=LEN(S)-1
30 FOR I=1 TO 11:OUT I,0:NEXT
40 A=#900
50 @LP:FORI=0TON
60 L=A+(PEEK(S+I)-224)*5:GSB@S
70 NEXT:GOTO@LP
80 @S:CLT:BEEP
90 @L:IFBTN()THENOUT0:VIDEO1:END
100 OUT 1+1968-PEEK(L)*16
110 OUT 2+1968-PEEK(L+1)*16
120 OUT 4+1968-PEEK(L+2)*16
130 OUT 8+1968-PEEK(L+3)*16
140 OUT 64+1968-PEEK(L+4)*16
150 IFTICK()>20:RTN
160 GOTO@L

タブを閉じる