Shop OBEX P1 Docs P2 Docs Learn Events
Strobes - Switching patterns? — Parallax Forums

Strobes - Switching patterns?

Nate#2Nate#2 Posts: 5
edited 2010-02-24 03:25 in BASIC Stamp
Hey there,

I'm trying to make a strobe light, and have succeeded thus far. I'm using the OUTH=% for terminals 8-12 (only 5 LED's available), and I looped it. If I use terminal 0 as an input switch for pattern switch, how should I do it? I can't figure it out for my life.

Code (Had to type it out, it's on another PC):
' {$STAMP BS2}
' {$PBASIC 2.5}

DO
OUTH= %00000
DIRH= %11111

OUTH= %11000
PAUSE 50
OUTH= %00000
PAUSE 50
OUTH= %11000
PAUSE 50
OUTH= %00000
PAUSE 50
OUTH= %11000
PAUSE 50
OUTH= %00000
PAUSE 30

OUTH= %00011
PAUSE 50
OUTH= %00000
PAUSE 50
OUTH= %00011
PAUSE 50
OUTH= %00000
PAUSE 50
OUTH= %00011
PAUSE 50
OUTH= %00000
PAUSE 50

LOOP




Something like that. That's basically the pattern.

Thanks for the help

-Nate

Post Edited (Nate#2) : 2/23/2010 3:05:45 AM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-02-23 03:00
    Somebody said...
    If I use terminal 0 as an input switch for pattern switch, how should I do it?
    Could you explain this further?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Nate#2Nate#2 Posts: 5
    edited 2010-02-23 03:02
    I was going to hook up an input switch on terminal 0 on my board, and I was wondering what code I would need to put my patterns in to be able to use input 0 to switch between that pattern and other programmed patterns. Does that make any more sense?
    -Nate
  • FranklinFranklin Posts: 4,747
    edited 2010-02-23 03:09
    You would use something like "if sw1 = 1 then do thispattern" Also they are called pins, terminals are a different thing in stamp language. Pin0 is part of the serial port and I would not recommend using that unless you understand the consequences.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Nate#2Nate#2 Posts: 5
    edited 2010-02-23 03:14
    Franklin said...
    You would use something like "if sw1 = 1 then do thispattern" Also they are called pins, terminals are a different thing in stamp language. Pin0 is part of the serial port and I would not recommend using that unless you understand the consequences.

    Oh, ok. So, use pin 1? If I do the whole "If in1=1 Then *pattern*", then it tells me to use an "ENDIF" at the end...and I'm not sure what I'd do on it.

    Thanks a lot!
    -Nate
  • FranklinFranklin Posts: 4,747
    edited 2010-02-23 03:17
    I guess I'm just not understanding what it is you want, sorry.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Nate#2Nate#2 Posts: 5
    edited 2010-02-23 03:22
    Yeah, kind of hard to explain. Basically, I guess, I want to use P1 to go from the alternating 3 flash I have set now, to a different pattern, and I'm curious as to what I have to do with my code to make that work.

    If I use "If in1=1 THEN", it gives me the error of "No ENDIF"...and I don't know how to fix that...or what I'm doing wrong.

    Hope that helps. Just PM me if you're still confused, I guess.
    -Nate
  • Oper8r AlOper8r Al Posts: 98
    edited 2010-02-23 04:33
    Nate#2

    Check out the syntax and reference manual. It gives you a full explanation of the IF - THEN statements. You can download it from the parallax site. Here is a link:

    www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-02-24 03:22
    Try This might be what you are looking for

    Pick_One:

    DO

    IF IN0 = 1 THEN pattern1
    ELSE
    IF IN1 = 1 THEN pattern2
    ENDIF
    ENDIF

    LOOP


    pattern1:
    DEBUG "pattern1"
    PAUSE 1000
    RETURN

    pattern2:
    DEBUG "pattern1"
    PAUSE 1000
    RETURN

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam
  • Nate#2Nate#2 Posts: 5
    edited 2010-02-24 03:25
    Thanks, guys. I got it figured out enough to make it work...it's got about 5 different strobe patterns in it.
Sign In or Register to comment.