Random Function

The random function returns a random number.

random(int max)

Returns a random number.

Input

You need to give it an int called max as an input. This int is the biggest number you random is allowed to return to you as a result.

Returns

It returns an int between 0 and the the max input.

Example

// creates a variable called number // sets the number variable to a random value between 0-100 int number = random(100); // prints the number to Serial Serial.println(number);

Tips

This function is useful when you want to have unpredictable results. For example you could use random(6) to simulate rolling a die.

x

Hi awesome backer,

Thanks again for supporting us on Kickstarter or Indiegogo.

On this website you can access the learning videos and documentation. You'll need to sign up for an account but it shouldn't take long and allows us to remember your video progress so you don't have to keep track of that.

We hope you have a great time learning with Awesome Shield.


Close Message