The BS1's RANDOM statement will generate a sequence of 16-bit unsigned pseudo-random numbers (ranging from 0 to 65535). Look at the description of this statement in the Basic Stamp Manual or the Editor's help files for details. You'll have to do some adjustment of the numbers you get from RANDOM to fit the range you want. You want a range of 3000 starting at 1000. Typically, you'd divide the result of the RANDOM statement by the range you want and take the remainder, then add the starting value. The remainder or modulus operator is "//".
I'm not a programmer, and don't really want to dedicate hours to learning the process. Do you have a few lines of BS1 working code I can look at and run. Then I can see what the numbers do and swap the figures to make it work for my application. I'm not ashamed to borrow code. THANKS
You're going to have to learn something about programming a BS1, about entering a program, compiling it, and downloading it to the BS1. What are you really wanting to do? Do you just want a list of "random" numbers displayed on your computer's screen? Remember that these numbers are not really random, they're just "pseudo-random" numbers produced by a linear feedback shift register. They have some properties of random numbers, but they're not really random. In fact, you'll get the same sequence of numbers each time you start your program unless the program is written to add some kind of random event to the mix (like a human initiated keypress).
To get a pseudo-random number in the range you wanted, you'd do:
RANDOM variable
variable = variable // 3000 + 1000
You'll need some other statements to make a complete program and display the results, but you'll need to look at the DEBUG statement description and a description of how to define variables from the Stamp Manual (Basic Stamp Syntax and Reference Manual). You'll also need to look at the GOTO statement and how to define labels. The "What's a Microcontroller?" tutorial is a good reference for starting to program. It should be in the Editor's help files or you can download it from Parallax.
The code makes sense, I'll try it. I saw that the other random numbers I produced with the BS1 started to repeat after 20 or so iterations (using the 0-255 set). My device will be totally unattended and without human intervention, once the power comes on, it does its thing over and over and over. Hopefully the numbers I need 1000 to 3999 will be random enough. I've programmed in assembly, Basic, Fortran and Cobol, but that was a couple of decades ago. It may be a sad comment on my life that dabbling in micocontrollers is fun, but maybe profitable. Thanks again for the real code.
Actually, the code I showed needs a little change:
RANDOM variable1
variable2 = variable1 // 3000 + 1000
The reason is that RANDOM takes the initial contents of the variable and changes it. To get a pseudo-random sequence, you have to use the changed variable value the next time you use RANDOM.
Comments
To get a pseudo-random number in the range you wanted, you'd do:
RANDOM variable
variable = variable // 3000 + 1000
You'll need some other statements to make a complete program and display the results, but you'll need to look at the DEBUG statement description and a description of how to define variables from the Stamp Manual (Basic Stamp Syntax and Reference Manual). You'll also need to look at the GOTO statement and how to define labels. The "What's a Microcontroller?" tutorial is a good reference for starting to program. It should be in the Editor's help files or you can download it from Parallax.