How to have Pause as a Random Amount of Time and have OutPut also Random
sam_sam_sam
Posts: 2,286
Hi, EveryOne
I would like to have some· ·on how to do this
I am at it again
I·want to learn how to have·PAUSE VALUE·for a·RANDOM amount of·TIME
Is there an easy way to this
I did look in the BS2 files and found an example of using random command but that will not work for what i want to
I also look in Stamp's online help and examples do not help me·any
I don't think it will
I also look in· Fourm Search and did not find an example that i could use
This is what i have in mind
Pause Values are as follows this is only an example here
·The more Random the Better I would also like to not repeat the same routine over and over
I would also like to make the outputs to be·random· as well if this can be done
DO
toggle 8
Pause 100 ' This lowest value
toggle 9
Pause 500
toggle 10
Pause 1000
toggle 11
Pause 200
toggle 12
Pause·120
toggle 13
Pause·1500
toggle 14
Pause· 65535 The max value
toggle 15
Loop
Toggle 15,9,12,8,11,14,9,13 and so on
I know that i could write it·this way·but it would keep repeating in the same order·and that is not what i am looking for
I hope that some out on the Forum can give an example how do this
Thanks to any one that can help in this matter
Sam
I would like to have some· ·on how to do this
I am at it again
I·want to learn how to have·PAUSE VALUE·for a·RANDOM amount of·TIME
Is there an easy way to this
I did look in the BS2 files and found an example of using random command but that will not work for what i want to
I also look in Stamp's online help and examples do not help me·any
I don't think it will
I also look in· Fourm Search and did not find an example that i could use
This is what i have in mind
Pause Values are as follows this is only an example here
·The more Random the Better I would also like to not repeat the same routine over and over
I would also like to make the outputs to be·random· as well if this can be done
DO
toggle 8
Pause 100 ' This lowest value
toggle 9
Pause 500
toggle 10
Pause 1000
toggle 11
Pause 200
toggle 12
Pause·120
toggle 13
Pause·1500
toggle 14
Pause· 65535 The max value
toggle 15
Loop
Toggle 15,9,12,8,11,14,9,13 and so on
I know that i could write it·this way·but it would keep repeating in the same order·and that is not what i am looking for
I hope that some out on the Forum can give an example how do this
Thanks to any one that can help in this matter
Sam
Comments
[noparse][[/noparse]code]
z···· VAR·· WORD
100 RANDOM z
····· IF z < 100 THEN 100
····· PAUSE z
····· ' Anything else you want after the pause
[noparse][[/noparse]/code]
Thank You for your Post This helps alot
This is what i came up with i am not able to·test this·tonight but i will test it soon
' {$STAMP BS2}
' {$PBASIC 2.5}
Z··· VAR··· Word
Y··· VAR··· Byte
x··· VAR··· Word
s··· VAR··· Byte
RANDOM Z : RANDOM Y : RANDOM X : RANDOM S
DO
TOGGLE 8
PAUSE Z
TOGGLE 9
PAUSE Y
TOGGLE 8
PAUSE X
TOGGLE 9
PAUSE S
IF Z· OR· X· < 100 THEN
x = 500
z = 800
ENDIF
IF y· OR· s· < 50 THEN
y = 100
s = 150
ENDIF
LOOP
I tried to write it the way you had wrote the routine but it would not complie it·so worte this
Can you tell if this writen the right way
·Sam
produce the same results because they're "pseudo-random". They produce a sequence that's
reproducible, but behaves statistically as if it were random (by using a linear feedback shift
register). Since you're starting all four with zero, the two word variables will be the same and
the two byte variables will be the same.
Sorry for the coding error. I was thinking of standard Basic, not PBasic.
Thanks for your post.
That help me alot to understand how to use the RANDOM command.
I will try this over the weeken .
I bought these Christmas Candy Cane from Kmart
They just have plain lights in them
I thought that it would be cool to have them blink ON and OFF randomly all eight of them at different times
Yes i know your going to tell that i have to much time on my hands
This is what my wife tell me but i say that am going to learn something
by doing this project
Sam