The random function generates pseudo-random numbers.
- min: lower bound of the random value, inclusive (optional).
- max: upper bound of the random value, exclusive.
- A random number between min and max-1. Data type: long.
The code generates random numbers and displays them.
※ NOTES AND WARNINGS:
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.
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.
The max parameter should be chosen according to the data type of the variable in which the value is stored. In any case, the absolute maximum is bound to the long nature of the value generated (32 bit - 2,147,483,647). Setting max to a higher value won't generate an error during compilation, but during sketch execution the numbers generated will not be as expected.
※ ARDUINO BUY RECOMMENDATION
|Arduino UNO R3 Buy on Amazon|
|Official Arduino Starter Kit Buy on Amazon|
|ELEGOO UNO R3 Starter Kit Buy on Amazon|