Shop OBEX P1 Docs P2 Docs Learn Events
programing help: I need to check a range. — Parallax Forums

programing help: I need to check a range.

Philip T.Philip T. Posts: 8
edited 2006-07-20 18:52 in BASIC Stamp
I have a Variable called Gyro.
If this VAR is between 740 and 760 I need my program to skip a couple of lines of code.
How do I code this?
thanks in advance.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-19 12:57
     if Gyro < 740 then DoIt
     if Gyro > 760 then DoIt
     goto SkipIt
    DoIt: <couple of lines of code>
    SkipIt:
    
    
  • Philip T.Philip T. Posts: 8
    edited 2006-07-19 14:41
    Does this work?
    IF gyro<760 AND gyro>740 THEN SkipState
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-19 14:53
    Yes. I wanted to provide an example that would work with any Stamp and the BS1 is quite restricted in the complexity of expressions.
  • Philip T.Philip T. Posts: 8
    edited 2006-07-19 15:43
    Sorry should have specified BSII
  • Tom WalkerTom Walker Posts: 509
    edited 2006-07-20 15:06
    Philip,
    If you can give me a value for Gyro that fulfills your conditions....:^)

    In short, I think that you are looking for OR instead of AND in the way you have it coded...

    Keep 'em comin'...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • Philip T.Philip T. Posts: 8
    edited 2006-07-20 17:20
    If the value of Gyro is from 740-760 I don't need to run the code for the next couple of steps.
    My gyro returns a value of 750 when my Trooper is still. It uses the full range when driveing down the road straight.
    Actually about 743 to 757. The BSII controlls the shockabsorbers extending and retracting to counter roll in a corner.
    My old code would just bank left to if above 760 and bank right below 740.
    The new code watches the Gyro value and looks for a shift in it. This way it can change states before I Pass through "the dead zone".
    So the Line of code I need is for when the truck is running straight down the road to avoid cycling the hydralics.
    I hope this isnt to wordy.
    Here's the Hydralic schematics. And my latest Code if you are realy bored.
  • Tom WalkerTom Walker Posts: 509
    edited 2006-07-20 18:52
    Sorry Philip....I just went a little dyslexic and thought you had your limits reversed...you are correct...

    mea culpa

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
Sign In or Register to comment.