title: OpMode stuck in stop() Android studio
body: <p>We are making a parking code for FTC Skystone where a color sensor is looking for a change in hue value to stop the robot. It works most times, but if we press the stop button, the code continues and errors out with an OpMode is stuck in stop(). </p>
  
  <p>Other than that, The sensor will only read it four out of five times, and we have no clue of what else to do to get this to work. 
  Here is our code:</p>
  
  <pre><code>@Override
  public void runOpMode(){
  
      // Drive train initialization
      motorFrontRight = hardwareMap.dcMotor.get("FR");
      motorFrontLeft = hardwareMap.dcMotor.get("FL");
      motorBackLeft = hardwareMap.dcMotor.get("BL");
      motorBackRight = hardwareMap.dcMotor.get("BR");
  
      motorFrontLeft.setDirection(DcMotor.Direction.FORWARD);
      motorFrontRight.setDirection(DcMotor.Direction.REVERSE);
      motorBackLeft.setDirection(DcMotor.Direction.FORWARD);
      motorBackRight.setDirection(DcMotor.Direction.REVERSE);
  
      // Color sensor initialization
      sensorColor = hardwareMap.get(ColorSensor.class, "color_sensor");
      color2 = hardwareMap.get(ColorSensor.class, "color2");
      sensorDistance = hardwareMap.get(DistanceSensor.class, "color_sensor");
  
      // Color Sensor Values
      float hsvValues[] = {0F, 0F, 0F};
      final float values[] = hsvValues;.
      final double SCALE_FACTOR = 255;
  
      telemetry.addData("Status: ", "Initialized");
      telemetry.addData("&gt;", "Press Play to start op mode");
      telemetry.update();
      waitForStart();
  
      while (opModeIsActive()){
          // Color Sensor Code
  
          Color.RGBToHSV((int) (color2.red() * SCALE_FACTOR),
                  (int) (color2.green() * SCALE_FACTOR),
                  (int) (color2.blue() * SCALE_FACTOR),
                  hsvValues);
          Color.RGBToHSV((int) (sensorColor.red() * SCALE_FACTOR),
                  (int) (sensorColor.green() * SCALE_FACTOR),
                  (int) (sensorColor.blue() * SCALE_FACTOR),
                  hsvValues);
  
          // Send the info back to driver station using telemetry function.
          telemetry.addData("Step: ", step);
          telemetry.addData("Hue", hsvValues[0]);
          telemetry.update();
  
          // Move forward
          if (step == 0){
              motorFrontRight.setPower(.2);
              motorFrontLeft.setPower(.2);
              motorBackLeft.setPower(.2);
              motorBackRight.setPower(.2);
          }
  
          // Does it see the line?
          while (step == 0){
              if (opModeIsActive()){
                  Color.RGBToHSV((int) (sensorColor.red() * SCALE_FACTOR),
                          (int) (sensorColor.green() * SCALE_FACTOR),
                          (int) (sensorColor.blue() * SCALE_FACTOR),
                          hsvValues);
                  Color.RGBToHSV((int) (color2.red() * SCALE_FACTOR),
                          (int) (color2.green() * SCALE_FACTOR),
                          (int) (color2.blue() * SCALE_FACTOR),
                          hsvValues);
  
                  // Send the info back to driver station using telemetry function.
                  telemetry.addData("Step: ", step);
                  telemetry.addData("Hue", hsvValues[0]);
                  telemetry.update();
              }
              if (hsvValues[0] &gt; 150 ){ // Checks if it is red or blue
                  step++;
              }
          }
  
          if (step == 1){
              motorFrontRight.setPower(0);
              motorFrontLeft.setPower(0);
              motorBackLeft.setPower(0);
              motorBackRight.setPower(0);
              step++;
          }
  
          if (step == 2){
              motorFrontRight.setPower(-.5);
              motorFrontLeft.setPower(-.5);
              motorBackLeft.setPower(-.5);
              motorBackRight.setPower(-.5);
              sleep(200);
              step++;
          }
  
          if (step == 3){
              motorFrontRight.setPower(0);
              motorFrontLeft.setPower(0);
              motorBackLeft.setPower(0);
              motorBackRight.setPower(0);
          }
      }
  }
  </code></pre>