After much trial with random (dice roll always stopped on same number)
I decided change tack and try interupt as a solution. It appears to work!
Momentry Button on input 0 commences action. Code as follows:
dice:
setint %00000001,%00000001
main:
for b0= 0 to 5
low 1 ‘ switch output 1 off
pause 2000
next b0 ‘ wait 2 seconds
goto main
‘ loop back to start
interrupt:
gosub throw ‘ switch output 1 on
if pin1 = 1 then interrupt ‘ loop here until the
‘ interrupt cleared
pause 2000 ‘ wait 2 seconds
setint %00000001,%00000001 ‘ re-activate interrupt
return ‘ return from sub
throw:
faster:
pause 50
let b6=2
goto chase
chase:
for b5=1 to 40
inc b6
pause b6
pins=%00000001
pause b6
pins=%00000010
pause b6
pins=%00000100
pause b6
pins=%00001000
pause b6
pins=%00010000
pause b6
pins=%00100000
pause b6
pins=%00000000
if b6=40 then reveaL
next b5
reveal:
if b0=0 then goto one
if b0=1 then goto two
if b0=2 then goto three
if b0=3 then goto four
if b0=4 then goto five
if b0=5 then goto six
return
one:
high 0
wait 4
low 0
return
two:
high 1
wait 4
low 1
return
three:
high 2
wait 4
low 2
return
four:
high 3
wait 4
low 3
return
five:
high 4
wait 4
low 4
return
six:
high 5
wait 4
low 5
return
I would be interested in any comments.
I decided change tack and try interupt as a solution. It appears to work!
Momentry Button on input 0 commences action. Code as follows:
dice:
setint %00000001,%00000001
main:
for b0= 0 to 5
low 1 ‘ switch output 1 off
pause 2000
next b0 ‘ wait 2 seconds
goto main
‘ loop back to start
interrupt:
gosub throw ‘ switch output 1 on
if pin1 = 1 then interrupt ‘ loop here until the
‘ interrupt cleared
pause 2000 ‘ wait 2 seconds
setint %00000001,%00000001 ‘ re-activate interrupt
return ‘ return from sub
throw:
faster:
pause 50
let b6=2
goto chase
chase:
for b5=1 to 40
inc b6
pause b6
pins=%00000001
pause b6
pins=%00000010
pause b6
pins=%00000100
pause b6
pins=%00001000
pause b6
pins=%00010000
pause b6
pins=%00100000
pause b6
pins=%00000000
if b6=40 then reveaL
next b5
reveal:
if b0=0 then goto one
if b0=1 then goto two
if b0=2 then goto three
if b0=3 then goto four
if b0=4 then goto five
if b0=5 then goto six
return
one:
high 0
wait 4
low 0
return
two:
high 1
wait 4
low 1
return
three:
high 2
wait 4
low 2
return
four:
high 3
wait 4
low 3
return
five:
high 4
wait 4
low 4
return
six:
high 5
wait 4
low 5
return
I would be interested in any comments.