title: Arduino: Servo "doesn't work" with IR
body: <p>I'm trying to make a little type of "mechanical arm" for my project at school. </p>
  
  <p>My problem is: when the claw gets something the servo stops and the IR goes crazy. I tried everything I know but nothing is working and the project is running late...</p>
  
  <p>This is similar to my project but I don't have the shield:</p>
  
  <p><a href="https://i.stack.imgur.com/2hoE0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2hoE0.jpg" alt="enter image description here"></a></p>
  
  <pre><code>#include &lt;IRremote.h&gt; 
  #include &lt;Servo.h&gt;
  
  #define rec A1 
  #define claw 5
  
  Servo g;    
  bool i = false;
  IRrecv irrecv(rec);
  decode_results results;
  
  void setup() {
    Serial.begin(9600);
    g.attach(claw);
    g.write(25);
    irrecv.enableIRIn(); 
  }
  
  void loop(){
    if(irrecv.decode(&amp;results)){
      delay(250); 
      Serial.println(results.value);
      if(results.value == 551522925) {
        i = !i;
        change(i);
      }
    }
  }
  
  void change(bool i) {
    switch (i) {
      case false:
        g.write(0);
        break;
      case true:
        g.write(25);
        break;
      }
  }
  </code></pre>