Serial monitor infinite output

first of all, i want to thank all of u guys who replied in this post... kudos to all of u! :wink:

my problem is solved, although it seems that it doesn't involve the floating pin issue... i already fixed my problem by putting an inverter from my input device going to the arduino... LOL.

here's my code which makes our hexapod move in 4 directions:

#define forwardPin  12
#define backwardPin  11
#define rightPin  10
#define leftPin  9

int forwardState = 0;
int backwardState = 0;
int rightState = 0;
int leftState = 0;


void setup()
{
  Serial.begin(9600);
  pinMode(forwardPin, INPUT);
  pinMode(backwardPin, INPUT);
  pinMode(rightPin, INPUT);
  pinMode(leftPin, INPUT);
}

void loop()
{
  forwardState = digitalRead(forwardPin);
  backwardState = digitalRead(backwardPin);
  rightState = digitalRead(rightPin);
  leftState = digitalRead(leftPin);
  if (forwardState == HIGH && backwardState == LOW && leftState == LOW && rightState == LOW)
  {
    Serial.write("\x02" "8,1500,50,9,900,50,10,1500,50,11,1400,50,12,1500,50,13,900,50,4,1500,50,5,1500,50,2,1000,50,3,1400,50,0,1500,50,1,1500,50" "\x03");
    delay(100);
    Serial.write("\x02" "8,1500,50,9,1500,50,10,1000,50,11,900,50,12,1500,50,13,1500,50,4,1000,50,5,1500,50,2,1000,50,3,1000,50,0,1000,50,1,1500,50" "\x03");
    delay(100);
    Serial.write("\x02" "8,1000,50,9,900,50,10,1500,50,11,900,50,12,1000,50,13,900,50,4,1000,50,5,900,50,2,1500,50,3,1400,50,0,1000,50,1,900,50" "\x03");
    delay(100);
  }
  else if (backwardState == HIGH && forwardState == LOW && leftState == LOW && rightState == LOW)
  {
    Serial.write("\x02" "1,1500,50,5,1500,50,0,1000,50,4,1000,50,3,1000,50,2,1500,50,13,1500,50,9,1500,50,8,1000,50,12,1000,50,11,1000,50,10,1500,50" "\x03");
    delay(100);
    Serial.write("\x02" "1,1000,50,3,1000,50,5,1000,50,9,1500,50,11,1500,50,13,1500,50,0,1500,50,4,1500,50,2,1000,50,8,1500,50,12,1500,50,10,1000,50" "\x03");
    delay(100);
    Serial.write("\x02" "1,1000,50,5,1000,50,3,1500,50,0,1000,50,2,1000,50,4,1000,50,8,1500,50,10,1500,50,12,1500,50,9,1000,50,13,1000,50,11,1500,50" "\x03");
    delay(100);
  
  }
  else if (rightState == HIGH && forwardState == LOW && backwardState == LOW && leftState == LOW)
  {
    Serial.write("\x02" "1,1500,50,3,1500,50,5,1500,50,9,2000,50,11,2000,50,13,2000,50,0,1500,50,2,1000,50,4,1500,50,8,1500,50,10,1000,50,12,1500,50" "\x03"); 
    delay(100);
    Serial.write("\x02" "1,1500,50,3,1000,50,5,1500,50,9,1500,50,11,2000,50,13,1500,50,0,1000,50,2,1000,50,4,1000,50,8,1500,50,10,1500,50,12,1500,50" "\x03"); 
    delay(100);
    Serial.write("\x02" "1,1000,50,3,1500,50,5,1000,50,9,2000,50,11,1500,50,13,2000,50,0,1000,50,2,1500,50,4,1000,50,8,1000,50,10,1500,50,12,1000,50" "\x03"); 
    delay(100);
  
  }
  else if (leftState == HIGH && forwardState == LOW && backwardState == LOW && rightState == LOW)
  {
    Serial.write("\x02" "8,1500,50,9,1000,50,10,1500,50,11,1500,50,12,1500,50,13,1000,50,5,1000,50,4,1000,50,1,1000,50,0,1000,50,3,500,50,2,1000,50" "\x03");
    delay(100);
    Serial.write("\x02" "8,1500,50,9,1500,50,10,1000,50,11,1000,50,12,1500,50,13,1500,50,5,500,50,1,500,50,0,1500,50,4,1500,50,3,1000,50,2,1000,50" "\x03");
    delay(100);
    Serial.write("\x02" "8,1000,50,9,1000,50,10,1500,50,11,1000,50,12,1000,50,13,1000,50,3,500,50,2,1500,50,1,500,50,5,500,50,0,1000,50,4,1000,50" "\x03");
    delay(100);
  }
  else
  {
    Serial.write("\x02" "8,400,50,9,400,50,10,400,50,11,400,50,12,400,50,13,400,50,5,400,50,4,400,50,1,400,50,0,400,50,3,400,50,2,400,50" "\x03");
  }
}

again, i want to thank all of u guys ^^
hopefully u will still help me if i encounter any problems.. Godbless :blush: