B4R Question Random Number

Discussion in 'B4R Questions' started by lamviec4, Aug 8, 2019.

  1. lamviec4

    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Johan Schoeman

    Johan Schoeman Expert Licensed User

    janderkan likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice