PDA

View Full Version : Strobes - Switching patterns?



Nate#2
02-23-2010, 09:53 AM
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

Franklin
02-23-2010, 10:00 AM
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#2
02-23-2010, 10:02 AM
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

Franklin
02-23-2010, 10:09 AM
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#2
02-23-2010, 10:14 AM
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

Franklin
02-23-2010, 10:17 AM
I guess I'm just not understanding what it is you want, sorry.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Nate#2
02-23-2010, 10:22 AM
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 Al
02-23-2010, 11:33 AM
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 (http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf)

sam_sam_sam
02-24-2010, 10:22 AM
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·http://forums.parallax.com/images/smilies/idea.gif·that you may have and all of your time finding them http://forums.parallax.com/images/smilies/smile.gif

·
·
·
·
Sam

Nate#2
02-24-2010, 10:25 AM
Thanks, guys. I got it figured out enough to make it work...it's got about 5 different strobe patterns in it.