Shop OBEX P1 Docs P2 Docs Learn Events
RCTIME command Basic Stamp 2 — Parallax Forums

RCTIME command Basic Stamp 2

PhlisPhlis Posts: 2
edited 2008-02-18 22:13 in BASIC Stamp
Hi all,

I am a starter to Basic·Stamp 2.

I am working on a project using the RCTIME command, to light up an LED within a certain RC range (25 to·30) and turn off the LED out of this range. I adjust the 10K potentio meter (with a 0.1UF capacitor) connected to the Basic Stamp 2 input pin 4. I can vary the speed by turning the potentio meter with this command:

' {$STAMP BS2}

··· speed VAR Word
·· Loop:
··· HIGH 4 'discharge the capacitor
··· PAUSE 1 'for 1 milisecond
····RCTIME 4,1,speed
··· DEBUG ? speed
··· IF (25>speed<30) THEN do
··· do:
·· HIGH 12
·· RETURN

What command do I use to turn off the LED when the speed is out of this range?

Your help is much appreciated.

Thank You.

Comments

  • UghaUgha Posts: 543
    edited 2008-02-18 20:46
    Just a suggestion... try something like this:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    speed VAR Word

    DO
    ·HIGH 4
    ·PAUSE 100 'need more time on your pause command
    ·RCTIME 4, 1, speed
    ·DEBUG ? speed
    ·IF(speed > 25 AND speed < 30) THEN
    · HIGH 12
    ·ELSE
    · LOW 12
    ·ENDIF
    LOOP

    END

    I haven't tested the above but it should work... it'll keep the LED on if its in range, or if its out, turn it off.
  • PhlisPhlis Posts: 2
    edited 2008-02-18 22:13
    Hi Ugha,

    Thank you so much for your suggestion. It worked exactly the way I wanted.

    Thanks again.
Sign In or Register to comment.