Serial monitor infinite output

zer0_JuLz:
so the new code will be like this?

Why not try it and tell us?

With those 1 second delays you're not going to read more than the fact a signal was sent from the remote and that only by luck.

Try keeping track of what state the pin was last time it was read and only printing when the state changed. Then take the delays out. But fix the wiring first.

PaulS:

  pinMode(forwardPin, INPUT);

digitalWrite(forwardPin, HIGH); // Turn on the pullup resistor.

will it also work if i make it a pull down resistor? some like...

pinMode(forwardPin, INPUT);
  digitalWrite(forwardPin, LOW); // Turn on the pulldown resistor

No, there are no built in pulldowns

AWOL:
No, there are no built in pulldowns

thanks sir that helped a lot ^^

pinMode(forwardPin, INPUT);
digitalWrite(forwardPin, LOW);   // turn off the pull-up resistor

All that second line does is turn off the pull-up. There had to be a way of doing it, and this is it.

oh really sir?! gee thanks! i will try it now

Do you know how to wire a pull-down resistor?

arduinohabib:
Do you know how to wire a pull-down resistor?

yes sir i read about it

I'm really not used to someone calling me sir :slight_smile: :slight_smile: :slight_smile: check my profile. Just call me Habib :slight_smile:

arduinohabib:
I'm really not used to someone calling me sir

I don't like being called that since I was enlisted and take being called sir as an insult.
Many people just don't understand. Sir is the guys I took orders from but learned never to trust.

Call me crazy, but when people call me "sir" I become wary.

Um well it's mainly because my age.

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:

I'm glad you fixed the problem, but that has no resemblance to the code in the first post on this thread.