Ghost in my stepper motor

I an using an Arduino UNO with a stepper motor, stepper driver, and separate power supply for the motor and driver. the driver takes an input for step and direction, the direction is either set to HIGH or LOW and the step is sent as a pulse voltage. when using my stepper motor and program everything works as intended except that periodically the stepper take a "set of steps" in either direction. by "set of steps" I am referring to how ever many steps the prgram is set for when the "IN" or "OUT" is pressed. Please help me out. This is my first Arduino project and i need to get it finished up for school. Any help will be much appreciated.

const int steppulse=4;
const int directionofstep=3;

int buttonin=0;
int buttonout=0;
int count=0;
int gotozero=0;
int Zeropoint=0;
int zero=0;
int gohome=0;
int sethome=0;
int homepos=0;
int cutteron=0;
int cutteroff=0;
int jog_stepper=0;


void setup(){
  pinMode(steppulse,OUTPUT);
  pinMode(directionofstep, OUTPUT);
  pinMode(5,INPUT_PULLUP);
  pinMode(6,INPUT_PULLUP);
  pinMode(7,INPUT_PULLUP);
  pinMode(8,INPUT_PULLUP);
  pinMode(9,INPUT_PULLUP);
  pinMode(10,INPUT_PULLUP);
  pinMode(1,INPUT_PULLUP);
  pinMode(2,INPUT_PULLUP);
  pinMode(12,INPUT_PULLUP);
}
void loop(){
  buttonout=digitalRead(5);
  buttonin=digitalRead(6);
  gotozero=digitalRead(7);
  Zeropoint=digitalRead(8);
  gohome=digitalRead(9);
  sethome=digitalRead(10);
  cutteron=digitalRead(1);
  cutteroff=digitalRead(2);
  jog_stepper=digitalRead(12);

  if (buttonout==LOW){                   //out

    for (int x=0; x<100; x++){
      digitalWrite(directionofstep,HIGH);
      digitalWrite(steppulse,LOW);
      delay(1);
      digitalWrite(steppulse,HIGH);
      delay(1);
    }
    count=count-200;
  }
  if (buttonin==LOW){                //in

    for (int x=0; x<100; x++){
      digitalWrite(directionofstep,LOW);
      digitalWrite(steppulse,LOW);
      delay(1);
      digitalWrite(steppulse,HIGH);
      delay(1);
    }
    count=count+200;
  }
  if (gotozero==LOW){                        //go to zero

    for (int x=0; x<abs(0-count+zero); x++){

      digitalWrite(directionofstep,HIGH);
      digitalWrite(steppulse,HIGH);
      if (digitalRead(12) ==LOW){ 
        delay(1);
      }
      else {
        delay(5);
      }


      digitalWrite(steppulse,LOW);
      if (digitalRead(12)==LOW){ 
        delay(1);
      }
      else {
        delay(5);
      }


    }
    count=zero;
  }

  if (Zeropoint==LOW){                          //set zero
    zero=count;
  }


  if (gohome==LOW){                   //moves out to set home position

    for (int x=0; x<abs(0-count+homepos); x++){
      digitalWrite(directionofstep,LOW);
      digitalWrite(steppulse,HIGH);
      if (digitalRead(12)==LOW){
        delay(1);
      }
      else {
        delay(5);
      }
      digitalWrite(steppulse,LOW);
      if (digitalRead(12)==LOW){
        delay(1);
      }
      else {
        delay(5);
      }

    }
    count=homepos;
  }
  if (sethome==LOW){                        //set the home position
    homepos=count;
  }


}

Which section of code is executing when the unwanted steps occur? You can use Serial.print() to find out. What event has caused that code to execute? Again, Serial.print() is your friend. I suspect you'll find that you're getting a spurious input state change, perhaps because of a floating pin or wiring fault, but that's only a guess and you should track it down methodically.

I can't help you modify the code but I think I can tell you how to find out which routine is causing the problem.
You can try this method while you wait for someone else to solve your problem.
Step 1.
Insert a Serial.begin(9600)l statement in your Setup.
step-2
Insert Serial.print("routine-#1"); statements in EVERY routine.
step -3
Insert delay(1000); statements at the END of EVERY routine. (this MAY need to be increased later)
step-4
get a clipboard with a notepad on it. (IF YOU HAVE A STOPWATCH or can use your cell phone as one do that)
step-5
sit down and run your program with serial monitor open so you can watch the motor.
step-6
start the stopwatch when you click run (This technique works much better if you add a pushbutton to you setup that start the motor routine when you press it so you can synchronize your stopwatch) (also, If you read the "Blink Without Delay IDE Example code and learn how to use millis(); statement you can print out millis AT THE START OF each routine and use the stopwatchto cross-reference the time to locate the suspect routine.)
step-7
After you start the program and the stopwatch , watch the motor and STOP the stop watch when you see the anomoly.
look at the watch , AND the program. look at the printouts and locate the last routine stopwatch reading to the millis printout millis printout that matches your stopwatch reading. When you find it, that's where the anomoly is. If you have a friend (or your mom or sister/brother, garderner/passerby (just kidding) you can enlist then have them sit at the computer and watch the printouts and when you see the anomoly yell "NOW!" and ask them to identify the routine that was printing out when you said "NOW."

Try running your stepper WITHOUT the usb-cable connected.
Your PC serial 'talks' to FDTI approx every 32 secs.

Good tip! That could be it.

FYI the computer is never connected when the stepper is in use.

this is the part of the code that is executing unexpectedly. there are to possibilities here, either the " if buttonout==LOW" or "if buttonin==low"

 if (buttonout==LOW){                   //out

    for (int x=0; x<100; x++){
      digitalWrite(directionofstep,HIGH);
      digitalWrite(steppulse,LOW);
      delay(1);
      digitalWrite(steppulse,HIGH);
      delay(1);
    }
    count=count-200;
  }
  if (buttonin==LOW){                //in

    for (int x=0; x<100; x++){
      digitalWrite(directionofstep,LOW);
      digitalWrite(steppulse,LOW);
      delay(1);
      digitalWrite(steppulse,HIGH);
      delay(1);
    }
    count=count+200;
  }

I will attempt the serial.print features.
thx

fI am using an Arduino UNO with a stepper motor, stepper driver, and separate power supply for the motor and driver. the driver takes an input for step and direction, the direction is either set to HIGH or LOW and the step is sent as a pulse voltage. when using my stepper motor and program everything works as intended except that periodically the stepper take a "set of steps" in either direction. by "set of steps" I am referring to how ever many steps the prgram is set for when the "IN" or "OUT" is pressed. Please help me out. This is my first Arduino project and i need to get it finished up for school. Any help will be much appreciated.

Does it say anything here about a button ?
Did you try the suggestion in Reply#2 ?

Don't use pin 1 as an input, that is being used by the serial port.
Add some decoupling capacitors to try and isolate your motor supply from the arduino.

  pinMode(1,INPUT_PULLUP);

BINGO !

Well I got it fixed but in a slightly different way. Last night I took the panel off the box and noticed ever time I touched a screwdriver to the terminal, the motor would move. From this I concluded that it was grounding its self (which was the call to move in or out) anyway it could. I had another switch that disconnected the circuit instead of connecting when the button was pressed. I tried this while reversing the states for the if statements. This worked and I had no issues with it.