title: Arduino compile error on only certain programs
body: <p>I've been having a problem with my arduino compilor. What happens is if I run certain programs It results in a compiler error. On other programs every thing compiles normally. But If certain I run certain programs I get the error </p>
  
  <blockquote>
    <p>"exit status 1 Error compiling for board Arduino/Genuino Mega or Mega<br>
    2560."</p>
  </blockquote>
  
  <p>Here's the code I am trying to run:</p>
  
  <hr>
  
  <pre><code>#include &lt;AFMotor.h&gt;
  
  int px =0;
  int py = 0;
  int X;
  int Y;
  String serialData;
    AF_DCMotor right(3);
    AF_DCMotor left(4);
  void setup() {
    Serial.begin(9600);
    Serial.setTimeout(10);
    right.setSpeed(400);
    left.setSpeed(400);
  }
  
  
  void serialEvent() {
  serialData = Serial.readString();
    X = Xc(serialData);
    Y = Yc(serialData);
    if(X &lt; px){
      right.run(BACKWARD);
      left.run(BACKWARD);
      delay(X * 10);
      px = X;
    }
    right.run(RELEASE);
    left.run(RELEASE);
  }
  
  int Xc(String data){
    data.remove(data.indexOf("Y"));
    data.remove(data.indexOf("X"), 1);
    return data.toInt();
  }
  
  int Yc(String data){
    data.remove(0,data.indexOf("Y") + 1);
    return data.toInt();
  }
  </code></pre>
  
  <hr>
  
  <p>I've tried to compile for other boards but I still get the same error.</p>