I am writing a G-code interpreter and have run into a problem. When the X and Y axis get to their desired position (Right now I just have it return the axis and a .01 unit movement over serial) they just move +0.01 and -0.01 back and forth.

#include <WString.h> // include the String libraryString inString = String(50); // allocate a new String for the incoming group of chars.String units = String(2); // allocate a new String for the units setting. Inches or Milimeters.String xstr = String(10); // string for the X caricters to be dumped before thy become and double or float.String ystr = String(10); // string for the Y caricters to be dumped before thy become and double or float.String zstr = String(10); // string for the Z caricters to be dumped before thy become and double or float.double xCurrent = 0;double yCurrent = 0;double zCurrent = 0;

if (inChar == 'l'){ // If it is the end of the string decode the string and do the actions. char firstChar = inString.charAt(0); //start parsing string if (firstChar == 'G'){ //Is it a G-code GCodeParse(); } else if (firstChar == 'M'){//Is it an M-code MCodeParse(); } else{//If it is nether a G or M code send to the computer to continue. Serial.println("continue"); } //stop parsing and erase string inString = 0; } else{ inString.append(inChar); // if you're not at the end of the string, append the incoming character }