Random number -> Corresponding LED lit (n00besque content contained)


Results 1 to 14 of 14

Threaded View

  1. #9
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Random number -> Corresponding LED lit (n00besque content contained)

    I've tried to randomize 20 LEDs hooked up as shown in the attachment with the following code:
    (Sorry, I've had to retype it. Long story.)
    Code:
    clear
    define osc4
    ansel=0
    comcon0=7
    adcon0=0
     
    delay var word
    myword var word
    mybyte var byte
    previous_random var byte
    gpiostate var byte
    tristate var byte
     
    delay = 250
     
    main:
    random myword
    mybyte = (myword//20)
    if previous_random = mybyte then goto main
    gosub high_led
    pause delay
    gpio = %000000
    pause delay
    previous_random= mybyte
    goto main
     
    high led:
    lookup mybyte,[%000001, etc for 20 LEDs], gpiostate
    gpio = gpiostate
    lookup mybyte,[%111100, etc for 20 LEDs], tristate
    trisio = tristate
    return
    The problem I'm having is two fold.

    First, LED0 never lights. I've watched it for a about 3 minutes several times and that first LED never lights. Any ideas why?

    Secondly, although I implement the previous_random scheme shown previously in the thread, I often get an LED that will light repeatedly before moving on. Any ideas why?

    As always, most of your thoughts are appreciated.
    Attached Images Attached Images
    Last edited by Archangel; - 14th June 2011 at 04:57. Reason: CODE TAGS

Members who have read this thread : 0

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

Posting Permissions

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