Hi,
The random command is not working, when I press C.1 to start the sequence it goes straight through each time to 'showone'. Any suggestions as I am a little new at basic programming.
Thanks
Mark
serout B.7,N2400,(254,1);set B.7, as output for LCD
let dirsC = %00000000 ;set pinsC as inputs or outputs
let dirsB = %11111111 ;set pinsB as inputs or outputs(pin B.0
;symbol key_pos = b0 ; number of keys pressed
;symbol key_value = b1 ; value of key pressed
main:
random b1 ; generate a random number
pause 500 ; wait for display to initialise
serout B.7,N2400,(254,1) 'clear display
pause 30
serout B.7,N2400,(254,131) ; move to end of first line
serout B.7,N2400,("ENTER CODE") ;first line of code
if pinC.1 = 1 then makenumber ; test switch
goto main
makenumber:
Random b1
if b1 > 55000 then showsix ; test random number and jump
if b1 > 44000 then showfive
if b1 > 33000 then showfour
if b1 > 22000 then showthree
if b1 > 11000 then showtwo
showone:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("1")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showtwo:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("2")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showthree:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("3")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showfour:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("4")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showfive:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("5")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showsix:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("6")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
The random command is not working, when I press C.1 to start the sequence it goes straight through each time to 'showone'. Any suggestions as I am a little new at basic programming.
Thanks
Mark
serout B.7,N2400,(254,1);set B.7, as output for LCD
let dirsC = %00000000 ;set pinsC as inputs or outputs
let dirsB = %11111111 ;set pinsB as inputs or outputs(pin B.0
;symbol key_pos = b0 ; number of keys pressed
;symbol key_value = b1 ; value of key pressed
main:
random b1 ; generate a random number
pause 500 ; wait for display to initialise
serout B.7,N2400,(254,1) 'clear display
pause 30
serout B.7,N2400,(254,131) ; move to end of first line
serout B.7,N2400,("ENTER CODE") ;first line of code
if pinC.1 = 1 then makenumber ; test switch
goto main
makenumber:
Random b1
if b1 > 55000 then showsix ; test random number and jump
if b1 > 44000 then showfive
if b1 > 33000 then showfour
if b1 > 22000 then showthree
if b1 > 11000 then showtwo
showone:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("1")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showtwo:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("2")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showthree:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("3")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showfour:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("4")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showfive:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("5")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
showsix:
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("6")
wait 1
serout B.7,N2400,(254,195) ; move to start of second line
serout B.7,N2400,("#")
goto main
