Shop OBEX P1 Docs P2 Docs Learn Events
Stamp Triggering — Parallax Forums

Stamp Triggering

ArchiverArchiver Posts: 46,084
edited 2003-10-08 20:48 in General Discussion
My question is about how to setup the stamp to be triggered when say
a input pin gose high, and then run a program and wait once agian for
input to go high to run it once more....

in my sample program below:

MAIN:
input 2
IF IN2 = 0 THEN TB
IF IN2 = 1 THEN MAIN
TB:

debug "input is high"

input 2
IF IN2 = 1 THEN main
goto main

*****

now what seems to happen with this code hear (even thought i know
its detecting the low state of the pin) i have a 555 timmer setup to
read a photo transistor and on the other side of the transistor is a
IR emmiting led, so basicly if the two are pointed together it wont
run nothing or debug "input is high" but!.... if i break the line it
will keep looking "input is high,etc...." over and over , i just want
it to say it once, then if the IR sight is returned , do nothing ,
but if broken agian will debug "input is high" (not haveing the
sucker keep looping..)

im sure theres probley a better way to code this maybe someone with a
beter brain then me can figure it out, its anoying that this stupid
thing repeats it self even tho i just want it to do sorta like a "one
shot" and if the IR line sight is returned, but then broken once more
to repeat it self, and so on....

please help!


Sean...

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-10-08 20:44
    This routine is triggered when in2 goes from 0 to 1.

    main:
    main1:
    IF in2=1 THEN main1 ' stay in this loop while in2 is high
    main0: ' now it is low
    IF in2=0 then main0 ' stay in this loop while in2 is low
    ' fall through to TB when it goes high
    TB:
    debug "input went high"
    goto main

    or in PBASIC 2.5 syntax:

    main:
    DO : LOOP WHILE in1=1
    DO : LOOP WHILE in1=0
    TB:
    debug "input went high"
    goto main

    -- Tracy


    >My question is about how to setup the stamp to be triggered when say
    >a input pin gose high, and then run a program and wait once agian for
    >input to go high to run it once more....
    >
    >in my sample program below:
    >
    >MAIN:
    >input 2
    >IF IN2 = 0 THEN TB
    >IF IN2 = 1 THEN MAIN
    >TB:
    >
    >debug "input is high"
    >
    >input 2
    >IF IN2 = 1 THEN main
    >goto main
    >
    >*****
    >
    >now what seems to happen with this code hear (even thought i know
    >its detecting the low state of the pin) i have a 555 timmer setup to
    >read a photo transistor and on the other side of the transistor is a
    >IR emmiting led, so basicly if the two are pointed together it wont
    >run nothing or debug "input is high" but!.... if i break the line it
    >will keep looking "input is high,etc...." over and over , i just want
    >it to say it once, then if the IR sight is returned , do nothing ,
    >but if broken agian will debug "input is high" (not haveing the
    >sucker keep looping..)
    >
    >im sure theres probley a better way to code this maybe someone with a
    >beter brain then me can figure it out, its anoying that this stupid
    >thing repeats it self even tho i just want it to do sorta like a "one
    >shot" and if the IR line sight is returned, but then broken once more
    >to repeat it self, and so on....
    >
    >please help!
    >
    >
    >Sean...
    >
    >
    >To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    >from the same email address that you subscribed. Text in the
    >Subject and Body of the message will be ignored.
    >
    >
    >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-08 20:48
    Hi Sean,

    Lets clarify the hardware side of this problem. You mentioned that you
    are using IR LED and on the receiving side is a photo transistor. My
    question is, is the photo transistor is an IR receiver type or just
    ordinary detecting luminance type? Have you tried it out on a
    breadboard using the transistor to drive an LED to see if the two
    pairs really work?

    On the code side I see that you didn't balance the detection between
    the two state like this:

    MAIN:
    IF IN2 = 0 THEN MAIN
    IF IN2 = 1 THEN DISPLAY1
    GOTO MAIN

    DISPLAY1:
    DEBUG "Input is HIGH"

    TB:
    IF IN2 = 1 THEN TB
    IF IN2 = 0 THEN DISPLAY2
    GOTO TB

    DISPLAY2:
    DEBUG "Input is LOW"
    GOTO MAIN

    Cheers,

    - Johari




    --- In basicstamps@yahoogroups.com, "djrevolution99"
    <djrevolution99@y...> wrote:
    > My question is about how to setup the stamp to be triggered when say
    > a input pin gose high, and then run a program and wait once agian for
    > input to go high to run it once more....
    >
    > in my sample program below:
    >
    > MAIN:
    > input 2
    > IF IN2 = 0 THEN TB
    > IF IN2 = 1 THEN MAIN
    > TB:
    >
    > debug "input is high"
    >
    > input 2
    > IF IN2 = 1 THEN main
    > goto main
    >
    > *****
    >
    > now what seems to happen with this code hear (even thought i know
    > its detecting the low state of the pin) i have a 555 timmer setup to
    > read a photo transistor and on the other side of the transistor is a
    > IR emmiting led, so basicly if the two are pointed together it wont
    > run nothing or debug "input is high" but!.... if i break the line it
    > will keep looking "input is high,etc...." over and over , i just want
    > it to say it once, then if the IR sight is returned , do nothing ,
    > but if broken agian will debug "input is high" (not haveing the
    > sucker keep looping..)
    >
    > im sure theres probley a better way to code this maybe someone with a
    > beter brain then me can figure it out, its anoying that this stupid
    > thing repeats it self even tho i just want it to do sorta like a "one
    > shot" and if the IR line sight is returned, but then broken once more
    > to repeat it self, and so on....
    >
    > please help!
    >
    >
    > Sean...
Sign In or Register to comment.