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


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

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

    We really need to see the entire code esp. the lookup tables.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

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

    It worked perfectly for me ....any reason you have not copied the code verbatim?

    Re LED1 never lighting, what happens if you comment out the random aspect & simple make mybyte = 1 (where 1 is the LED you're not seeing lighting up etc)...this should light the suspect LED up all the time & proves both the wiring/LED at least.

    Re the same LED lighting in succession, I'd approach this by getting some debug/hserout info of 'mybyte' onscreen....else you're grasping in the dark. (no pun intended!)

  3. #3
    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 did run another program to ensure all the LEDs are hooked up and working. They all work using the cut and pasted look up tables provided.

    Hank, when you say it worked perfectly did you use the schematic I provided? The last time I chased a problem with these LEDs, it turned out to be the circuit not the code. If you look here http://www.picbasic.co.uk/forum/show...ght=wood+chuck you'll see what I mean.

    Here are the look up tables.

    lookup mybyte,[%000001, %000010, %000001, %000100, %000001, %010000, %000001, %100000, %000010, %000100, %000010, %010000, %000010, %100000, %000100, %010000, %000100, %100000, %010000, %100000], gpiostate
    gpio= gpiostate
    lookup mybyte,[%111110, %111100, %111010, %111010, %101110, %101110, %011110, %011110, %111001, %111001, %101101, %101101, %011101, %011101, %101011, %101011, %011011, %011011, %001111, %001111],tristate
    trisio= tristate

    I don't currently have the knowledge to display my number on screen but if the LED is lit by another program, proving it does work, then looking at a number will only tell me that the LEDs number never comes up.

  4. #4
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

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

    I wonder if someone could explain the
    "MyByte=(MyWord//6)+1" part? // = Remainder (Modulus)? It isn't clear to me what this is doing and how it is extracting the 6 variables.

    I need to randomize 8 LEDs and would like to understand it better.

    Thanks
    Bo

  5. #5
    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)

    If you do the math with a calculator you'll, in my opinion, never understand modulus. Use paper and pencil for some small numbers and you'll see how modulus works.

    I believe to randomize 8 LEDs all you need to do is change the 6 to an 8. Like
    Random myword
    mybyte=(myword//8)

    Depending on how you use mybyte depends on whether or not you need to +1 after myword//8.

    I'm sure someone will chime in and say I've messed up but there you have it.

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