Shop OBEX P1 Docs P2 Docs Learn Events
use divice with the poll option? — Parallax Forums

use divice with the poll option?

DonohoDonoho Posts: 3
edited 2005-01-20 20:22 in BASIC Stamp
I am using the BS2p.· The device i would like to poll is the GP2DO2 an IR sensor.· The problem is that the device sends a pulse.· The device will be used to detect objects.· The only way i can use right now is if i make it a subroutine and call it often during the main program.· I would like to have it outside the main program and interupt when it sees an object.· Please any advice is welcomed.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-20 20:22
    Of course, you cannot do interrupts with BASIC Stamps.· You can, however, simulate this process -- to a degree -- with careful coding.· Here's how I frequently construct programs that need a "background" feature:

    Main:
      GOSUB Background_Task
      ON task GOSUB Task0, Task1, Task2, Task3
      GOTO Main
    


    Dirt simple, isn't it?· With this construction your "background" task get sandwiched in between the main program tasks.· Put your tasks into subroutines, then let each task point to the next -- either the next in sequence or the next that should run based on some unexpected condition.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.