Shop OBEX P1 Docs P2 Docs Learn Events
Do Basic Stamps have a Random Number Generating Capability? — Parallax Forums

Do Basic Stamps have a Random Number Generating Capability?

TheMistakeMakerTheMistakeMaker Posts: 2
edited 2006-03-11 15:02 in BASIC Stamp
Hi,

I'd like to know if there is in the PBasic code a way to
generate random numbers.

I believe I've searched the entire Parallax forum section,
and have not found anything.

I'd aprpeciate any help. Thanks.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-11 15:02
    Yes, there's a RANDOM function -- you'll find it in our manual or online help file.· Do keep in mind that this is a pseudo-random function, so the best way to get true randomness is to introduce some outside random event.· In the EFX group we do a lot of prop building and the RANDOM function is very useful.· We us it like this:

    Main:
    · DO
    ··· RANDOM timer
    · LOOP WHILE (Trigger <> Active)

    This bit of code "stirs" the variable called timer until the trigger input is activated.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.