    {
       if(digitalRead(RSWITCH_PIN))
       {
-         current_l = MAX_STEPS;
+         g_sliderPos = MAX_STEPS;
          return -2;
       }
    }
-   DEBUG(current_l); DEBUG(" ");
+   DEBUG(g_sliderPos); DEBUG(" ");
    return 0;
 }
 

int checkPosition()
{
   float angle_d = getAngle(SHL);
   if ( abs( angle_d - current[SHL] ) > THRESHOLD3 ) return 1;
   DEBUG("Check1: "); DEBUGln(angle_d - current[SHL]);
   angle_d = getAngle(ELB) - angle_d;
   DEBUG("Check2: "); DEBUGln(angle_d - current[ELB] + 180);
   return ( abs( angle_d - current[ELB] + 180 ) > THRESHOLD3 );
}

// Read from accelerometers and determine angle from horizontal

// 'current' variables store the intended angles and 'actual' variables store the real angles used by servos
// e.g. for an elbow current angle of 180 (the elbow is in line with the shoulder) the real angle is around 0
int     i,j,count=0;
int     ret_val, g_moveDelay = 50; // g_moveDelay is defined at global scope and is used to control speed of arm
char    buf[MAX_BUFFER+1];
float   number[4], current[4], actual[4], g_angle_d[4];
float   g_radius_mm, g_height_mm, g_hand_d, g_sliderPos;
float   g_prevRadius_mm, g_prevHeight_mm, g_prevBase_d, g_prevHand_d;

const float gradient[] = {BAS_GRADIENT, SHL_GRADIENT, ELB_GRADIENT, WRI_GRADIENT, GRI_GRADIENT};
const float offset[] = {BAS_OFFSET, SHL_OFFSET, ELB_OFFSET, WRI_OFFSET, GRI_OFFSET};
