シフトレジスタで遊んでみました。
program SHIFREGdim i, j, k as byte
const pp=50main:
TRISIO = %00000000
'OPTION_REG.NOT_GPPU = 0
WPU = %00000100
GPIO = %00000000do
'CLEAR
GPIO.4 = 0
for i = 0 to 8
GPIO.2 = 1
GPIO.2 = 0
delay_ms(pp)
next i
delay_ms(pp*2)
'LEFT > RIGHT
GPIO.4 = 1
for i = 0 to 8
GPIO.2 = 1
GPIO.4 = 0
GPIO.2 = 0
delay_ms(pp)
next i
delay_ms(pp*2)
'RIGHT > LEFT
for j = 0 to 8
GPIO.4 = 1
for i = j to 8
GPIO.2 = 1
GPIO.4 = 0
GPIO.2 = 0
next i
delay_ms(pp)
for i= 8-j to 8
GPIO.2 = 1
GPIO.2 = 0
next i
next j
delay_ms(pp*2)
delay_ms(pp*2)'LEFT > RIGHT FILL
GPIO.4 = 1
for i = 0 to 7
GPIO.2 = 1
GPIO.2 = 0
delay_ms(pp)
next i
delay_ms(pp*2)
'ERASE
GPIO.4 = 0
for i = 0 to 7
GPIO.2 = 1
GPIO.2 = 0
delay_ms(pp)
next i
delay_ms(pp*2)'LEFT > RIGHT FILL
for k = 0 to 8
for j = 0 to k
GPIO.4 = 1
GPIO.2 = 1
GPIO.2 = 0
next j
GPIO.4 = 0
for i = j to 7
GPIO.2 = 1
GPIO.2 = 0
next i
delay_ms(pp)
next k
delay_ms(pp*2)'LEFT > RIGHT ERASE
for k = 0 to 7
for j = 0 to 7 - k
GPIO.4 = 1
GPIO.2 = 1
GPIO.2 = 0
next j
delay_ms(pp)
GPIO.4 = 0
for i = 0 to 7
GPIO.2 = 1
GPIO.2 = 0
next i
next k
delay_ms(pp*2)'FLASH
for k = 0 to 7
for j = 0 to 7
GPIO.4 = 1
GPIO.2 = 1
GPIO.2 = 0
next j
delay_ms(pp*2)
for i = 0 to 7
GPIO.4 = 0
GPIO.2 = 1
GPIO.2 = 0
next i
delay_ms(pp*2)
next k
delay_ms(pp*2)
loop until 0 = 1
end.
Mikrobasicにてプログラミング。この手の実験的な軽い開発には便利なツールですね。
難しかったのは、右から左への点灯です。
シフトレジスタは左から右への一方向へのシフトしかできないので、反対方向に流すにはコツがいります。