       case '=':
         resetEncoderPos();
         targetpos=0;
+        setTargetPos(90/10);
+        elbow.tgtPos=90;
+        wrist.tgtPos=90;
+        homing=true;
         break;
       case 'A':
         readcommand(state,controlvalue);


// =========== DC Control using the encoder.
int targetpos = 0;

void setTargetPos(int newtargetpos)
{
  targetpos = newtargetpos;
}

void updatedc(Adafruit_DCMotor *dcmotor, int currentpos)
{
  if (targetpos != currentpos)
  {
    dcmotor->setSpeed(90);

    if (targetpos < currentpos)
      dcmotor->run(FORWARD);
    else
      dcmotor->run(BACKWARD);

  } else {
    dcmotor->setSpeed(0);
  }

}


  updateEncoder();

  if (homing) {
    homing = !(updatedc(shoulder, (int)((getTilt()*180.0/PI)/(10.0))));
  
    if (!homing) {
      resetEncoderPos();
      setTargetPos(0);
    }
  
  }
  else {
    updatedc(shoulder, getEncoderPos());
  }
  //updaterotservo(elbow, getTilt());                                                           

  elbow.update();
