B4R Question Random Number


New Member
I am seeing something very strange. I am using the below code to generate a random number.
Sub p5_StateChanged

If p5click = False Then
Log("state 5 changed")
p5click = Not(p5click)
Dim num As Long = Rnd(0, 361)
Dim deg As Int = num
Log("DEG = ", deg)
Dim steps As Int = 4096 * (deg / 360)
For i = 0 To steps
stepcount = stepcount + steps
Log("Step Count = ", stepcount)
p5click = False
End If

End Sub
It does not matter if I recompile the B4R code, reset the UNO, power down and up the stepper motor and reset the UNO - the "random numbers generated always follow the same pattern from a "reset" i.e