Random
Source: Positron16 Compiler User Manual, PDF page 350
Syntax
Assignment Variable = Random
Overview
Generate a pseudo-randomised value.
Parameters
None. Assignment Variable is a user defined variable that will hold the pseudo-random value. The pseudo-random algorithm used has a working length of 1 to 65535.
Example
Device = 24HJ128GP502
' Select the device to compile for
Declare Xtal = 16
Dim wRandomValue as Word
wRandomValue = Random
' Get a pseudo random number into wRandomValue
Random wRandomValue
' Get a pseudo random number into wRandomValue
Note
All microcontrollers use a pseudo random number generator because they do not have a random noise generator peripheral, so the parameter that is used for Seed will always produce the same sequence of random values from the Random command.
It is important to be aware of this because each microcontroller will produce the same pseudo random values. If true random number generation is required, find a source of random noise that can be fed into the microcontroller’s ADC and use this value to place in the Seed command.