Random function

;D
what is a "real" random function without floating point variables ?

from the reference manual :

Variables .... Warning: floating point variables and operations are not currently supported.

char
int
long

try something with millis() !

AnalogRead return a value betwen 0 and 1024...
for my point of view, random function is not the most important thing to implement in Arduino.

with my friend Google i've found a pseudo random for VB6... can it help ?

Const xA = 16598013
 Const xC = 12820163
 Const xM = 16777216
 Const xI = 602453
 Dim Seed As Long
 
 Private Sub Form_Load()
     Seed = 327680
 End Sub
 
 'simule la Fonction Rnd()
 Private Function Random() As Single
     Dim s As Long
     Dim x As Currency
     x = CCur(xA) * Seed + xC
     Seed = x - Int(x / xM) * xM
     Random = Seed / xM
 End Function

CCur :
Converts expression to a Currency. CCur accepts any numeric or string data that
can be expressed as a currency value. The function recognizes the decimal and
thousands separators based on locale information on the client computer.

....

The Currency data type is actually an integer type internally. In use, it is scaled by a factor of 10,000 to give four digits to the right of the decimal point. It permits up to 15 digits to the left of the decimal point, resulting in a range of approximately -922,337,000,000,000 to +922,337,000,000,000. An individual type Currency variable takes up 8 bytes of memory, compared to 4 bytes for Single.

regards
eric