Random…. More like a scripted Sequence !!!


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: Random…. More like a scripted Sequence !!!

    If you have some user input on pic, you can use that for seed value by measuring time between button press and release. But again RANDOM just use some math and probably after some time repeat result.
    For dice I used this code:
    Main:
    For i = 1 to 6
    If button=pressed Then GoSub ShowResult
    Next i
    GOTO Main
    That is closest to random as you can get it. Result depending only on user button press. Variable will change value about 200 000 times in one second, so there is no way to repeat sequence...

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: Random…. More like a scripted Sequence !!!

    Hi,
    If the ADC aproach isn't working then using one of the PICs timers in freerunning mode to provide the seed might do it. For this to work the execution of time between each instance of the random instruction must not be constant.

    /Henrik.

Similar Threads

  1. Replies: 13
    Last Post: - 5th September 2010, 01:55
  2. How to set sequence of interrupt for PIC
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st June 2008, 11:17
  3. FOR sequence is skipped
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th August 2006, 02:35
  4. Installation sequence
    By Demon in forum General
    Replies: 23
    Last Post: - 11th July 2006, 03:56
  5. Switch Sequence
    By Tissy in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 13th February 2005, 20:36

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts