Pages: [1]   Go Down
Author Topic: [ask] how random fungction actually work ?  (Read 2631 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hai guys. im new in arduino so please forgive if i have something wrong while i post it smiley
so the real probelm:

im just want to know how actually "random function" on arduino work .? how it can randomly choose something ? (example we set "random(1,9)" and it can randomly choose number from 1 - 9) anyone please explain the random function?

thx for your support
-galuh boy-
smiley
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 210
Posts: 13030
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
im just want to know how actually "random function" on arduino work .?

https://www.google.com/search?q=pseudo+random+number+generator

https://www.google.com/search?q=minimal+standard+random+number+generator

Quote
how it can randomly choose something ?

It can't.  The function gives the appearance of being random.  For most applications that is good enough.

Quote
(example we set "random(1,9)" and it can randomly choose number from 1 - 9)

One to eight.  The maximum value is exclusive...
http://arduino.cc/en/reference/random

The Arduino random functions are simple functions layered on top of the Libc random function.  Values are mapped from 0 to RAND_MAX using modulus...
https://github.com/arduino/Arduino/blob/master/hardware/arduino/cores/arduino/WMath.cpp#L29
« Last Edit: July 05, 2014, 03:43:48 am by Coding Badly » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank for your support smiley
Logged

Pages: [1]   Go Up
Jump to: