Shop OBEX P1 Docs P2 Docs Learn Events
How to wait for a signal? — Parallax Forums

How to wait for a signal?

ArchiverArchiver Posts: 46,084
edited 2003-08-28 17:55 in General Discussion
Dear Freinds, Hi

I just registered in this group and this is my first message.
In my program I have to wait 30sec and if non of the input pins give
stamp a command, I should finish the program and turn of a relay.

I am not sure if there is a special command for these situations?
I am using a for-loop to check all the inputs each 100ms.

Please let me know if you have better suggestion.

Thank You Nima

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-08-28 17:17
    you should download/print out the basic stamp manual from
    parallax.com's download section. This is in there, but anyway:
    serin 1,16428,2000,NoData,[noparse][[/noparse]dec mydata]
    debug "got the data!",cr
    stop
    NoData:
    debug "didn't get data within 2 seconds!",cr

    you can change the 2000 number to reflect different times to wait for
    data before stopping the wait.



    --- In basicstamps@yahoogroups.com, "NIMA" <nimjah@y...> wrote:
    > Dear Freinds, Hi
    >
    > I just registered in this group and this is my first message.
    > In my program I have to wait 30sec and if non of the input pins
    give
    > stamp a command, I should finish the program and turn of a relay.
    >
    > I am not sure if there is a special command for these situations?
    > I am using a for-loop to check all the inputs each 100ms.
    >
    > Please let me know if you have better suggestion.
    >
    > Thank You Nima
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-28 17:41
    thank you so much

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    http://sitebuilder.yahoo.com
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-28 17:55
    The solution given assumes you are waiting for a
    232-type signal on each of the input pins -- is that
    the case?

    If you're looking for a level change (0 to 5V or
    5V to 0) then the given solution won't work for you.

    Also, you can only 'look' for a 232 type signal one
    pin at a time, since (as you should be aware) the BS2 is
    a single-tasking beast. This means it can only accept
    232 signals on the pin it is listening to at the time.

    There IS a 'timeout' parameter used in the example --
    but that just gives the 'sender' a window to send data
    in before it monitors the next pin.

    --- In basicstamps@yahoogroups.com, "NIMA" <nimjah@y...> wrote:
    > Dear Freinds, Hi
    >
    > I just registered in this group and this is my first message.
    > In my program I have to wait 30sec and if non of the input pins
    give
    > stamp a command, I should finish the program and turn of a relay.
    >
    > I am not sure if there is a special command for these situations?
    > I am using a for-loop to check all the inputs each 100ms.
    >
    > Please let me know if you have better suggestion.
    >
    > Thank You Nima
Sign In or Register to comment.