Shop OBEX P1 Docs P2 Docs Learn Events
boe bot LED flashing — Parallax Forums

boe bot LED flashing

zx1shadowzx1shadow Posts: 5
edited 2011-09-13 20:46 in BASIC Stamp
hi guys a pretty basic question im sure (no pun intended) but how can i loop a led flash program for a set amount of time.BASIC stamp 2.5 in a boe bot

Comments

  • FranklinFranklin Posts: 4,747
    edited 2011-09-12 20:57
    If you post the code you have and ask specific questions on why it does not do what you want perhaps we could help.
  • RDL2004RDL2004 Posts: 2,554
    edited 2011-09-12 22:20
    [HTML]SomeNumber VAR Word 'can be up to 65,535

    FOR SomeNumber = 1 To 60
    HIGH 1
    PAUSE 500
    LOW 1
    PAUSE 500
    NEXT[/HTML]

    Blinks an LED on Pin 1 once a second for 60 secs (approximately).

    Is that what you meant by "a set period of time"?
  • zx1shadowzx1shadow Posts: 5
    edited 2011-09-13 14:05
    well guys what im trying to get is a continiuous loop to make my led's flash,thats easy but i dont know how to make that loop last a set time e.g 3 seconds.I can get the desired effect by repeating a simple code but there must be a better way.The code follows.:smile:

    PULSOUT 1, 40000
    PULSOUT 10, 40000
    PAUSE 200
    PULSOUT 1, 40000
    PULSOUT 10, 40000
    PAUSE 200
    PULSOUT 1, 40000
    PULSOUT 10, 40000
    PAUSE 200
    PULSOUT 1, 40000
    PULSOUT 10, 40000
  • RDL2004RDL2004 Posts: 2,554
    edited 2011-09-13 20:46
    The answer is in my post. You need a loop, I used a FOR... NEXT loop. You don't really need to use PULSOUT. You can, but I used TOGGLE. This is a little simpler and more clear. Try it.
    Number_of_Loops VAR BYTE    
    
    '30 loops x 100 millisecs = 3 secs (well, there's some code overhead, but it's close)
    
    FOR Number_of_Loops = 1 to 30     'number of times to loop
    TOGGLE 1                          'pin 1 high one time, low the next time
    PAUSE 100                         'delay in millisecs before next time through the loop (flash rate of LED)
    NEXT
    
Sign In or Register to comment.