Random Function using index
userjyjy
Posts: 30
in BASIC Stamp
I'm working on a project where i need my seven seg to act as a dice and to randomize. I can't seem to figure out how to use the random function with the index. I currently have a button controlling the seven seg. When I press and hold it currently counts from 0 to 9 whenever i release it stops on whatever number it is.
Here is my code
"' {$STAMP BS2}
' {$PBASIC 2.5}
index VAR NIB
DO
DEBUG ? IN0
IF (IN0 = 1) THEN
OUTH = %00000000
DIRH = %11111111
FOR index = 0 TO 9
DO
LOOKUP index , [ %11100111, %10000100, %11010011,
%11010110, %10110100, %01110110,
%01110111, %11000100, %11110111, %11110110 ], OUTH
DEBUG " ", DEC2 index, " ", BIN8 OUTH, CR
PAUSE 1000
LOOP UNTIL IN0=1
NEXT
DIRH = %00000000
ENDIF
LOOP "
the random instruction seems to not be working with it.
Here is my code
"' {$STAMP BS2}
' {$PBASIC 2.5}
index VAR NIB
DO
DEBUG ? IN0
IF (IN0 = 1) THEN
OUTH = %00000000
DIRH = %11111111
FOR index = 0 TO 9
DO
LOOKUP index , [ %11100111, %10000100, %11010011,
%11010110, %10110100, %01110110,
%01110111, %11000100, %11110111, %11110110 ], OUTH
DEBUG " ", DEC2 index, " ", BIN8 OUTH, CR
PAUSE 1000
LOOP UNTIL IN0=1
NEXT
DIRH = %00000000
ENDIF
LOOP "
the random instruction seems to not be working with it.
Comments