PIC16F648を使った電子サイコロの製作
 
 
《mikroBasic PRO プログラム》
 program SAIKORO648
 
' Declarations section
 dim i as integer
 dim n as integer
 dim LDA as byte[7]
 dim LDB as byte[7]
 
main:
'  Main program
 LDA[0] = %00000000
 LDA[1] = %00000000
 LDA[2] = %00000100
 LDA[3] = %00000000
 LDA[4] = %00000100
 LDA[5] = %00000000
 LDA[6] = %00000100
 
 LDB[0] = %01010101
 LDB[1] = %10111011
 LDB[2] = %10101010
 LDB[3] = %10101010
 LDB[4] = %00100010
 LDB[5] = %10001000
 LDB[6] = %00000000
 
CMCON=%00000111
TRISA=%00000011
TRISB=0
n=0
mLoop:
 PORTA=LDA[n]
 PORTB=LDB[n]
 Delay_ms(100)
 n=n+1
 if PORTA.1=0 then
  goto DISP
 end if
 if n=6 then
  n=0
 end if
 goto mLoop
DISP:
 for i=1 to 6
  PORTA=LDA[i]
  PORTB=LDB[i]
  Delay_ms(1000)
 next i
 PORTA=LDA[n]
 PORTB=LDB[n]
 PORTA.3=1
 
waitSW:
 if PORTA.0=0 then
  goto mLoop
 end if
goto waitSW
end.
 
■プリント基板のパターン

電子サイコロのシミュレーション ダウンロード
PIC-BASICシミュレーション ダウンロード
技術科教育ホームページにもどる