B4R Question Random Number

lamviec4

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
cs.stepSingle(True)
Next
stepcount = stepcount + steps
Log("Step Count = ", stepcount)
Else
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
 
Top