The BASIC Stamp has a random number command, RANDOM. For complete details, consult the Stamp manual. Each time RANDOM is called, a new random number between 0 and 65,535 is generated. The same sequence will be generated each time the Stamp is powered up unless some means is used to generate a random seed number.
The following code snippet prints a new random number on the screen every quarter of a second.
rnum var word loop: random rnum debug dec ? rnum pause 250 goto loop
Here is a program that generates a random seed depending on when a button is pushed. This means that if a machine is started with a button push, a random action can happen for each run.
rand.bs2 -- random number demo code