Shop OBEX P1 Docs P2 Docs Learn Events
IR remote and servos — Parallax Forums

IR remote and servos

chris joneschris jones Posts: 391
edited 2013-03-20 17:01 in General Discussion
Hello,

i am trying to get my servos to work with my IR remote when i click volum up it moves to the right and volume down to the left but my if statement seems to always run right .

CODE ATTACHED

  repeat                                   'main loop                                                 
    code := Get_IR_Code(IR_PIN, THRESHOLD_CNT)
    if code > 0
      pc.hex(code,4)
     pc.char(" ")
     '' pc.bin(code,32)
     pc.char(13)
      if code == 0127
      servo.Set(1, 40)                                  ' Set servo to approximately -45° 
      time.Pause(1000)   
      servo.Disable(1)                                    ' Stop servo si
      if code  == 0125
      servo.Set(1, -40)                                  ' Set servo to approximately -45° 
      time.Pause(1000)   
      servo.Disable(1)                                    ' Stop servo si


Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2013-03-20 17:01
    I'm still looking at your code, but right off the bat, it might be indention (or lack thereof) that is causing part of your problem?

      repeat                                   'main loop                                                 
        code := Get_IR_Code(IR_PIN, THRESHOLD_CNT)
        if code > 0
            pc.hex(code,4)
            pc.char(" ")
         '' pc.bin(code,32)
            pc.char(13)
            if code == 0127
               servo.Set(1, 40)                                  ' Set servo to approximately -45° 
               time.Pause(1000)   
               servo.Disable(1)                                    ' Stop servo si
            if code  == 0125
               servo.Set(1, -40)                                  ' Set servo to approximately -45° 
               time.Pause(1000)   
               servo.Disable(1)                                    ' Stop servo si
    
    
Sign In or Register to comment.