Seed16, Rnd16()

Returns a Random number between 0 and 65,535.

The Pseudo Random Number Generator is based on a Linear feedback shift register (LFSR). You must initialize the generator with Seed16 prior to your first call to Rnd(). A sporadic call to Seed16 increases the probability of a random number. There is a chance of returning a zero value when the LFSR jumps to the idle state. It is therefore recommended to vary the position and Seed starting values in your code until you get a constant and evenenly spread random value.

Syntax: Seed16 Expression
Syntax: result = Rnd16()

Example

  [..]
  ' Load the Random Generator with a arbitrary starting value
  Seed16 0x1a74
  ' permanently output random numbers
  do
    print str(Rnd16())
    waitms 200
  loop