Shop OBEX P1 Docs P2 Docs Learn Events
continuos loop, continuos data input — Parallax Forums

continuos loop, continuos data input

sara lidgeysara lidgey Posts: 3
edited 2005-11-06 02:45 in BASIC Stamp
Hi All,

Is it possible to have my BS2 stamp running a continous loop and at the same time constantly wait for and accept input(SERIN) to change variables used in the loop. I am new to this, obviously.
>Sara

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-11-06 01:14
    Yes, it is.· At some point in your loop, say after the first variable, you could write serin pin, baud, 1000, cont, [noparse][[/noparse]first variable].· The program would wait for one second for a serin, then go to "cont", which would be a label entered right after the serin command.· The 1000 could be changed to however many seconds you can wait.· Does that help?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • NewzedNewzed Posts: 2,503
    edited 2005-11-06 01:18
    On second thought, it would be better to place the serin before the first variable.· This statement could be repeated just before successive variables.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • NewzedNewzed Posts: 2,503
    edited 2005-11-06 01:22
    I keep adding things.· You should write

    debug "Enter (first variable)".cr ·just before the serin statement, otherwise you won't know when to enter what.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • sara lidgeysara lidgey Posts: 3
    edited 2005-11-06 01:38
    Thanks for responding. Is the only option to put the SERIN in the actual loop? It may be that the stamp gets new input every minute or it could be hours between new data sent from the computer. It will vary. I'd rather not pause the loop to wait for SERIN, and if the computer is just sending data when it feels like it then the Stamp may miss the data if its someplace else in the loop at the time. I guess I could use SEROUT to ask the computer for the data at certain intervals, but I'd like to know if there was a simpler way.
    >Sara
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-11-06 02:45
    Sara,

    ·· What you will need to do is put the SERIN within the loop using a timeout if you need other things to happen while awaiting the input.· What else you do, and how quickly you get back to the SERIN will determine if this will work for you.· See the help file under the SERIN command for help on the timeout feature.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.