Random Function

The random function returns a random number.

random(int max)

Returns a random number.


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.


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


// 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);


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


Goodbye and thanks for all the fish,

Thanks for helping us Kickstart Awesome Shield and learning with us. Sadly, turning Awesome Shield into a sustainable business didn’t work out and so we’re in the process of officially shutting down the company.

Read our full letter.

If you have an Awesome Shield you can keep using it and the learning platform.

Close Message