Hide minor edits - Show changes to output

December 24, 2009, at 04:04 AM
by

- Changed lines 7-9 from:

long random(max)\\

long random(min, max)

long random(min, max)

to:

random(max)\\

random(min, max)

random(min, max)

Changed lines 16-17 from:

long - a random number between min and max - 1

to:

a random number between min and max-1 (''long'')

Changed lines 52-53 from:

* [[randomSeed]]

to:

* [[randomSeed]]()

October 13, 2008, at 05:11 PM
by

- Changed line 7 from:

long random(max)

to:

long random(max)\\

October 13, 2008, at 05:10 PM
by

- Changed lines 1-3 from:

!!long random(max) \\

long random(min, max)

long random(min, max)

to:

!!random()

Added lines 6-9:

!!!!Syntax

long random(max)

long random(min, max)

long random(max)

long random(min, max)

Changed lines 11-12 from:

min - lower bound of the random value, inclusive ''(optional parameter)''

to:

min - lower bound of the random value, inclusive ''(optional)''

September 27, 2007, at 06:06 AM
by

- Changed lines 16-17 from:

If it is important for sequence of values generated by random() to differ on subsequent executions of a sketch, use randomSeed() to initialize the random number generator with a fairly random input, such as analogRead() on an unconnected pin.

to:

If it is important for a sequence of values generated by random() to differ, on subsequent executions of a sketch, use randomSeed() to initialize the random number generator with a fairly random input, such as analogRead() on an unconnected pin.

September 27, 2007, at 05:53 AM
by

- Changed line 29 from:

// noise will cause the calls to randomSeed() to generate

to:

// noise will cause the call to randomSeed() to generate

Changed line 31 from:

// randomSeed() then shuffles the random function

to:

// randomSeed() will then shuffle the random function.

September 27, 2007, at 05:51 AM
by

- September 27, 2007, at 05:50 AM
by

- Changed lines 18-19 from:

Conversely, it can occasionally be useful to use pseudo-random sequences that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number.

to:

Conversely, it can occasionally be useful to use pseudo-random sequences that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number, before starting the random sequence.

September 27, 2007, at 05:49 AM
by

- Changed lines 8-9 from:

min - lower bound of the random value, inclusive (optional parameter)

to:

min - lower bound of the random value, inclusive ''(optional parameter)''

September 27, 2007, at 05:49 AM
by

- Changed lines 8-9 from:

min - lower bound of the random value, inclusive (optional parameter)

to:

min - lower bound of the random value, inclusive (optional parameter)

September 27, 2007, at 05:48 AM
by

- Changed lines 8-11 from:

min - lower bound on the random value, inclusive (optional)

max - upper bound on the random number, exclusive

max - upper bound on the random number, exclusive

to:

min - lower bound of the random value, inclusive (optional parameter)

max - upper bound of the random value, exclusive

max - upper bound of the random value, exclusive

September 27, 2007, at 05:46 AM
by

- Changed lines 26-27 from:

Serial.begin(19200);

to:

Serial.begin(9600);

Added lines 43-44:

delay(50);

September 27, 2007, at 05:44 AM
by

- Deleted line 39:

Deleted line 42:

September 27, 2007, at 05:44 AM
by

- Changed lines 29-30 from:

// noise will cause the calls to random() to generate

// different numbers each time the sketch runs.

// different numbers each time the sketch runs.

to:

// noise will cause the calls to randomSeed() to generate

// different seed numbers each time the sketch runs.

// randomSeed() then shuffles the random function

// different seed numbers each time the sketch runs.

// randomSeed() then shuffles the random function

Deleted lines 35-38:

// print a random number from 10 to 19

randNumber = random(10, 20);

Serial.println(randNumber);

randNumber = random(10, 20);

Serial.println(randNumber);

Added lines 38-42:

Serial.println(randNumber);

// print a random number from 10 to 19

randNumber = random(10, 20);

// print a random number from 10 to 19

randNumber = random(10, 20);

Added line 44:

September 27, 2007, at 05:41 AM
by

- Changed lines 18-19 from:

Conversely, it can occasionally be useful to use sequences pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number.

to:

Conversely, it can occasionally be useful to use pseudo-random sequences that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number.

Changed lines 28-29 from:

// if analog input pin 0 is unconnected, this

// will cause the calls to random() to generate

// will cause the calls to random() to generate

to:

// if analog input pin 0 is unconnected, random analog

// noise will cause the calls to random() to generate

// noise will cause the calls to random() to generate

September 27, 2007, at 05:00 AM
by

- Changed lines 5-6 from:

The random function allows convenient access to pseudo-random numbers for use in sketches.

to:

The random function generates pseudo-random numbers.

Changed lines 8-21 from:

min - optional starting range (ie: from "50" - 300).

max - the largest random number returned (plus one).

In the current version of this function, the max parameter will not be returned, although the minimum will, so for example:

[@random(10); // returns numbers from 0 to 9 @]

[@random(-5, 5); // returns numbers from -5 to 4 @]

Consequently, enter a maximum parameter one larger than the maximum integer desired.

'''min''' and '''max''' are long integers so numbers between -2,147,483,648 and 2,147,483,647 are valid.

max - the largest random number returned (plus one).

In the current version of this function, the max parameter will not be returned, although the minimum will, so for example:

[@random(10); // returns numbers from 0 to 9 @]

[@random(-5, 5); // returns numbers from -5 to 4 @]

Consequently, enter a maximum parameter one larger than the maximum integer desired.

'''min''' and '''max''' are long integers so numbers between -2,147,483,648 and 2,147,483,647 are valid.

to:

min - lower bound on the random value, inclusive (optional)

max - upper bound on the random number, exclusive

max - upper bound on the random number, exclusive

Changed lines 13-14 from:

long - the random number.

to:

long - a random number between min and max - 1

Changed lines 16-19 from:

If it is important for a random number sequence to ''begin'' on a random number, then call the randomSeed() function using something for a parameter that is fairly random, such as millis(), or analogRead() on a pin with no electrical connection.

Conversely, it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed() with the same number as a parameter.

Conversely, it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed() with the same number as a parameter.

to:

If it is important for sequence of values generated by random() to differ on subsequent executions of a sketch, use randomSeed() to initialize the random number generator with a fairly random input, such as analogRead() on an unconnected pin.

Conversely, it can occasionally be useful to use sequences pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number.

Conversely, it can occasionally be useful to use sequences pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number.

Added lines 27-31:

// if analog input pin 0 is unconnected, this

// will cause the calls to random() to generate

// different numbers each time the sketch runs.

randomSeed(analogRead(0));

Changed lines 34-42 from:

void loop(){

randomSeed(analogRead(0));

// return a random number from 50 - 300

randNumber = random(50,301);

// example with only a range, which would return

// a number between 0 - 300

// randNumber = random(301);

Serial.println(r);

randomSeed(analogRead(0));

// return a random number from 50 - 300

randNumber = random(50,301);

// example with only a range, which would return

// a number between 0 - 300

// randNumber = random(301);

Serial.println(r);

to:

void loop() {

// print a random number from 10 to 19

randNumber = random(10, 20);

Serial.println(randNumber);

// print a random number from 0 to 299

randNumber = random(300);

Serial.println(randNumber);

// print a random number from 10 to 19

randNumber = random(10, 20);

Serial.println(randNumber);

// print a random number from 0 to 299

randNumber = random(300);

Serial.println(randNumber);

Changed lines 47-48 from:

* [[millis]]

to:

September 27, 2007, at 04:37 AM
by

- Changed lines 10-11 from:

max - the largest random numbers you'd like returned.

to:

max - the largest random number returned (plus one).

Changed lines 18-19 from:

Consequently, enter a maximum parameter one larger than the maximum integer dersired.

to:

Consequently, enter a maximum parameter one larger than the maximum integer desired.

Changed lines 23-24 from:

long - returns the random number.

to:

long - the random number.

Changed lines 26-29 from:

If it is important for a random number series to ''begin'' on a random number, then call the randomSeed() function using something for a parameter that is fairly random, such as millis(), or analogRead() on a pin with no electrical connection.

Conversely it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed with the same number.

Conversely it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed with the same number.

to:

If it is important for a random number sequence to ''begin'' on a random number, then call the randomSeed() function using something for a parameter that is fairly random, such as millis(), or analogRead() on a pin with no electrical connection.

Conversely, it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed() with the same number as a parameter.

Conversely, it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed() with the same number as a parameter.

September 27, 2007, at 04:31 AM
by

- Changed lines 42-43 from:

randNumber = random(50,300);

to:

randNumber = random(50,301);

Changed line 46 from:

// randNumber = random(300);

to:

// randNumber = random(301);

September 27, 2007, at 04:31 AM
by

- Changed lines 26-27 from:

If it is important for a random number series to ''begin'' on a random number, then call the randomSeed() function using something that is fairly random such as millis() or analogRead() on a pin with no electrical connection.

to:

If it is important for a random number series to ''begin'' on a random number, then call the randomSeed() function using something for a parameter that is fairly random, such as millis(), or analogRead() on a pin with no electrical connection.

September 27, 2007, at 04:30 AM
by

- Changed lines 25-26 from:

!!!!Note: If it is important for a random number series to ''begin'' on a random number, then call the randomSeed() function using something that is fairly random such as millis() or analogRead() on a pin with no electrical connection.

to:

!!!!Note:

If it is important for a random number series to ''begin'' on a random number, then call the randomSeed() function using something that is fairly random such as millis() or analogRead() on a pin with no electrical connection.

If it is important for a random number series to ''begin'' on a random number, then call the randomSeed() function using something that is fairly random such as millis() or analogRead() on a pin with no electrical connection.

September 27, 2007, at 04:29 AM
by

- Changed lines 25-26 from:

Note: If it is important for a random number series to begin on a random number then call the randomSeed() function using something that is fairly random such as millis() or analogRead() on a pin with no electrical connection.

to:

!!!!Note: If it is important for a random number series to ''begin'' on a random number, then call the randomSeed() function using something that is fairly random such as millis() or analogRead() on a pin with no electrical connection.

September 27, 2007, at 04:29 AM
by

- Changed lines 5-6 from:

The random function allows convenient access to pseudo-random numbers for use in an applications. NOTE: Use this after using the randomSeed() function.

to:

The random function allows convenient access to pseudo-random numbers for use in sketches.

Changed lines 12-13 from:

In the current version of this function, the max parameter will not be returned, although the minimum will so, for example:

to:

In the current version of this function, the max parameter will not be returned, although the minimum will, so for example:

[@random(10); // returns numbers from 0 to 9 @]

[@random(10); // returns numbers from 0 to 9 @]

Changed lines 18-19 from:

Consequently enter a maximum parameter one more than the meximum dersired.

to:

Consequently, enter a maximum parameter one larger than the maximum integer dersired.

Added lines 25-28:

Note: If it is important for a random number series to begin on a random number then call the randomSeed() function using something that is fairly random such as millis() or analogRead() on a pin with no electrical connection.

Conversely it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed with the same number.

Conversely it can occasionally be useful to use pseudo-random numbers that repeat exactly. This can be accomplished by calling randomSeed with the same number.

September 27, 2007, at 04:17 AM
by

- Changed lines 5-6 from:

The random function allows you to return pseudo-random numbers for use in your applications. NOTE: Use this after using the randomSeed() function.

to:

The random function allows convenient access to pseudo-random numbers for use in an applications. NOTE: Use this after using the randomSeed() function.

Changed lines 10-11 from:

max - the overall range of random numbers you'd like returned.

to:

max - the largest random numbers you'd like returned.

In the current version of this function, the max parameter will not be returned, although the minimum will so, for example:

[@random(-5, 5); // returns numbers from -5 to 4 @]

Consequently enter a maximum parameter one more than the meximum dersired.

In the current version of this function, the max parameter will not be returned, although the minimum will so, for example:

[@random(-5, 5); // returns numbers from -5 to 4 @]

Consequently enter a maximum parameter one more than the meximum dersired.

September 27, 2007, at 03:23 AM
by

- Added lines 12-13:

'''min''' and '''max''' are long integers so numbers between -2,147,483,648 and 2,147,483,647 are valid.

May 27, 2007, at 02:33 AM
by

- May 27, 2007, at 02:32 AM
by

- Deleted lines 39-40:

[[HomePage | Reference Home]]

May 08, 2007, at 07:22 PM
by

- Deleted line 17:

int time;

Changed lines 25-26 from:

time = millis();

randomSeed(time);

randomSeed(time);

to:

randomSeed(analogRead(0));

September 15, 2006, at 06:21 PM
by

- Changed lines 1-3 from:

!!long random(max)

!!long random(min, max)

!!long random(min, max)

to:

!!long random(max) \\

long random(min, max)

long random(min, max)

September 15, 2006, at 06:21 PM
by

- Changed lines 1-2 from:

!!long random([min,] max)

to:

!!long random(max)

!!long random(min, max)

!!long random(min, max)

September 11, 2006, at 05:15 PM
by

- Changed lines 1-2 from:

!!long random([start,] range)

to:

!!long random([min,] max)

Changed lines 7-10 from:

start - optional starting range (ie: from "50" - 300).

range - the overall range of random numbers you'd like returned.

range - the overall range of random numbers you'd like returned.

to:

min - optional starting range (ie: from "50" - 300).

max - the overall range of random numbers you'd like returned.

max - the overall range of random numbers you'd like returned.

September 11, 2006, at 05:05 PM
by

- Added lines 29-32:

// example with only a range, which would return

// a number between 0 - 300

// randNumber = random(300);

September 11, 2006, at 05:04 PM
by

- Added lines 1-38:

!!long random([start,] range)

!!!!Description

The random function allows you to return pseudo-random numbers for use in your applications. NOTE: Use this after using the randomSeed() function.

!!!!Parameters

start - optional starting range (ie: from "50" - 300).

range - the overall range of random numbers you'd like returned.

!!!!Returns

long - returns the random number.

!!!!Example

[@

int time;

long randNumber;

void setup(){

Serial.begin(19200);

}

void loop(){

time = millis();

randomSeed(time);

// return a random number from 50 - 300

randNumber = random(50,300);

Serial.println(r);

}

@]

!!!!See also

* [[randomSeed]]

* [[millis]]

[[HomePage | Reference Home]]

!!!!Description

The random function allows you to return pseudo-random numbers for use in your applications. NOTE: Use this after using the randomSeed() function.

!!!!Parameters

start - optional starting range (ie: from "50" - 300).

range - the overall range of random numbers you'd like returned.

!!!!Returns

long - returns the random number.

!!!!Example

[@

int time;

long randNumber;

void setup(){

Serial.begin(19200);

}

void loop(){

time = millis();

randomSeed(time);

// return a random number from 50 - 300

randNumber = random(50,300);

Serial.println(r);

}

@]

!!!!See also

* [[randomSeed]]

* [[millis]]

[[HomePage | Reference Home]]