Trouble with while loops

Hello,

I have the following code:

int inPin = 13;
int outPin = 12;
int startTime = 0;

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
}

void loop()
{
  digitalWrite(outPin, LOW);
  [glow]while( pinMode(inPin) == LOW ) {}[/glow]
  startTime = millis;
  while( pinMode(inPin) == HIGH) { digitalWrite(outPin, HIGH); }
  digitalWrite(outPin, LOW);
  Serial.print( startTime - millis );
}

The highlighted line is where the error is occurring; something like, "too few arguments to function 'void pinMode(uint8_t, uint8_t)'". What does this mean and how can I get around it?

The point of the code is to wait until I press a button, then send output until I release it and print how long the button was pressed.

Thanks in advance for any help you give!

the problem is you are using pinMode (which needs two paramaters) where you intend digitalRead. I think something like this is what you want:

 void loop()
{
  digitalWrite(outPin, LOW);
  while( digitalRead(inPin) == LOW )
        ;   // do nothing while input is low
  startTime = millis;
  while(digitalRead(inPin) == HIGH) {   
     digitalWrite(outPin, HIGH);          
  }
  digitalWrite(outPin, LOW);
  Serial.print( startTime - millis );
}

note that most switches will bounce and this may give you erroneous readings. See the switch DeBbounce example sketch for more info on this.

Thank you very much! :)