Shop OBEX P1 Docs P2 Docs Learn Events
"case" — Parallax Forums

"case"

mikeamikea Posts: 283
edited 2012-12-30 05:17 in Propeller 1
Is there a better way to write the case range to test for values between 36" and 48"...the compiler says i need an expression term, not sure how to proceed. -thanks mike
       
repeat
 case state      'read state of pir
  0 : outa[5]~~  'red led on if no warm body detected
      outa[6..8]~
  1 : outa[5]~   'turn off red led
      outa[6]~~  'yellow led on if warm body detected
      case range               'use ping to see if dog is 36" to 48" from sensor
       >36 and <48 :outa[7]~~  'turn on green led...lucy is in the right spot, treadmill will soon start
                    outa[8]~~  'turn on transistor 4401 to pull in relay and power treadmill      

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-12-30 05:09
    case range
        37..47: ' do something here
    
    That is provided range actually delivers values in that area. See also The Manual (rev 1.2, around page 61).
  • kwinnkwinn Posts: 8,697
    edited 2012-12-30 05:14
    That would be 36..48 if you want it executed for anything from 36 to 48 as shown below. If you want >36 and <48 it would be 37..47
    repeat
     case state      'read state of pir
      0 : outa[5]~~  'red led on if no warm body detected
          outa[6..8]~
      1 : outa[5]~   'turn off red led
          outa[6]~~  'yellow led on if warm body detected
          case range               'use ping to see if dog is 36" to 48" from sensor
       36..48 :outa[7]~~  'turn on green led...lucy is in the right spot, treadmill will soon start
                        outa[8]~~  'turn on transistor 4401 to pull in relay and power treadmill
    
  • mikeamikea Posts: 283
    edited 2012-12-30 05:17
    kuroneko,kwinn thanks for the help i will try that.- mike
Sign In or Register to comment.