Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Is there a hold Feature for the I/O Pins — Parallax Forums

BS2 Is there a hold Feature for the I/O Pins

Jeff_5_Jeff_5_ Posts: 36
edited 2011-08-16 21:27 in BASIC Stamp
Is there a feature i can use to hold the state of a pin for a certain time while the program also continues.

Such as
High Pin #1 for 3000ms then it reverts back to low

Can this be done. I saw the RCTIME function but it didn't look like it would work.

I am doing a comparison in my program and i if my comparison is true i want to turn on an led for about 10 seconds then have it go back off automatically or stay on for another 10 seconds if the comparison is found true again.

Comments

  • Tom HoweTom Howe Guest Posts: 9
    edited 2011-08-16 20:48
    Would an IF THEN statement work for you maybe? Not quite sure the repeated comparison merits a GOSUB routine though. If you have the BASIC Stamp Syntax and Reference Manual, look up IF THEN and see if that will work for you.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-16 21:27
    No, there is no "hold" function. Generally, an I/O pin will stay in the same state until that is changed by another statement. Some statements will operate for a specified period of time, but the Stamp stops there until that time is up. One example of this is the PULSOUT statement. If you initialize an I/O pin to low (usually with a LOW statement), a PULSOUT <pin>,<time> statement will produce a high state for the specified time period, then the I/O pin will be left low. The PULSOUT statement will hang for the specified time, then continue. For the BS2, the time units are in units of 2us. Other Stamp models may use other time units (see the manual for details). If you want a long pulse, like 3000ms, you can write "HIGH <pin> : PAUSE 3000 : LOW <pin>" where <pin> is assumed to be low initially.
Sign In or Register to comment.