Shop OBEX P1 Docs P2 Docs Learn Events
Generating True Random with BS2 — Parallax Forums

Generating True Random with BS2

IceFireProIceFirePro Posts: 86
edited 2010-06-08 16:25 in BASIC Stamp
Hi everyone,

I am just starting off with my new BS2 and I have this question:

As I see, the RANDOM command in PB 2.5 is not real; it results in a particular number based on the seed, and if the seed is the same, the "random" number is the same. Pretty frustrating, isn't it?

Question: How to generate a true random number without user input? Is there a way to access Windows clock and go from there as a seed, or the system timer? Or use the photo-resistor, another sensor?

Thanks in advance!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-06-08 04:04
    Somebody said...
    or the system timer? Or use the photo-resistor, another sensor?
    That would be the best of the ways you mentioned.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • IceFireProIceFirePro Posts: 86
    edited 2010-06-08 04:11
    Thanks! But how do i access the PC's system timer thru BS2?
  • Spiral_72Spiral_72 Posts: 791
    edited 2010-06-08 16:25
    In BASIC it's:

    A = TIMER

    That gives you a floating point number of two?? decimal precision..... You'll need to make that an integer to directly send it across the serial port.


    A = INT(TIMER)
    OPEN ...... COM1, baud, blah, blah, and send "A"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "puff"...... Smile, there went another one.
Sign In or Register to comment.