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


Results 1 to 14 of 14

Threaded View

  1. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

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

    Hey Darrel...that works a treat ...I've now got pretty twinkly Blue leds randomly flashing before my eyes (which strangely, makes me feel warm inside).

    I note that a fair few of the random numbers are the same as the previous (I guess when you've only six to choose from, then that's bound to happen!), so I'll sit down for a few weeks & try & code this out!

    Many thanks!

    Hank.

    Edit: Actually, dialing out the successive repeats only took a couple of minutes...

    Code:
    MyWord var Word
    MyByte var Byte
    previous_random var Byte
    ;---------------------------------------
    Main:
        Random MyWord
        MyByte=(MyWord//6)+1
        if previous_random = MyByte then goto Main
        GOSUB HIGH_LED
        PAUSE 50
        GOSUB LOW_LED
        PAUSE 50
        previous_random = MyByte
    GOTO Main
    ;---------------------------------------
     
    HIGH_LED:
      SELECT CASE MyByte
        CASE 1 : HIGH LED1
        CASE 2 : HIGH LED2
        CASE 3 : HIGH LED3
        CASE 4 : HIGH LED4
        CASE 5 : HIGH LED5
        CASE 6 : HIGH LED6
      END SELECT
    RETURN
     
    ;---------------------------------------
    LOW_LED:
      SELECT CASE MyByte
        CASE 1 : LOW LED1
        CASE 2 : LOW LED2
        CASE 3 : LOW LED3
        CASE 4 : LOW LED4
        CASE 5 : LOW LED5
        CASE 6 : LOW LED6
      END SELECT
    Last edited by HankMcSpank; - 22nd April 2011 at 22:48.

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