Shop OBEX P1 Docs P2 Docs Learn Events
Random insanety — Parallax Forums

Random insanety

Last~Cell~LeftLast~Cell~Left Posts: 10
edited 2006-09-09 18:29 in BASIC Stamp
I am at a loss here.

My project idea is going well, between the internet, here and in books, I have been able to find all the right concepts I was looking for, minipulate the code to work in the ways that make my program function like wanted,

But yet, I am stuck,,,

1)·i have three leds,
2)·i have 3 buttons,

i·use this code to make the three leds marquee

FOR counter = 1 TO 10
· HIGH 8
· PAUSE 300
· LOW 8
· PAUSE 300
· HIGH 7
· PAUSE 300
· LOW 7
· PAUSE 300
· HIGH 13
· PAUSE 300
· LOW 13
· NEXT


Then I added this line



· HIGH 8
· PAUSE 300
··

·· timecounter = 0
·· DO
·· PAUSE 1
·· timecounter = timecounter + 1
···· LOOP UNTIL IN10 = 1

so now, when told to,,,,, the leds loop 10 times, then the last action is a high on output 8, the time counter kicks in and follwed by that is a list of

if < or >· then do " x "

is there a way to allow the counter to do it's thing,

then instead of me having to manualy program which led to light," HIGH·8 "·have the stamp random select a led to light after the counter is finished?

If anyone is interested in giving a hand,i am more then willing to answer any questions if this post is lacking in any direction.


Thanks in advance.


Kyle

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-09 16:48
    You need a word variable called "seed" or something else if you want. In your program initialization, set it to something (doesn't matter). In your time loop, after the PAUSE, put the statement "RANDOM seed". Now you have a random number from 0 to 65535. You can reduce this range to select one of three LEDs by using the modulus (//) operator:
      LOOKUP seed//3,[noparse][[/noparse]8,7,13],ledNum
      HIGH ledNum
      PAUSE 300
      LOW ledNum
    
    


    Does this help?
  • Last~Cell~LeftLast~Cell~Left Posts: 10
    edited 2006-09-09 18:29
    Mike,


    thanks for the Lead,,,,

    I am going to mess with this idea, see what I come up with.

    I'll keep you posted, but i think your on the right page.....



    thanks

    Kyle
Sign In or Register to comment.