How to clear a Pin?

Hi, I have the following.

void setup() {
  pinMode(clickPin,INPUT_PULLUP);  // currently pin D10
  digitalWrite(clickPin,HIGH);
}

void readPin(uint8_t aVal) {
//  delay(200);  // See below why this is here
  boolean myClick = !digitalRead(clickPin);
  if (myClick) {
    OK = true;
//    digitalWrite(clickPin,LOW);
//    digitalWrite(clickPin,HIGH);
    return aVal;
}

If I call readPin() it works fine, but if I call it two or more times in rapid succession, it falls straight through for the subsequent calls.

If I put the "delay(200);" in it goes back to working OK for all calls. I tried the two REMed digitalwrite, but same again. The delay works and it is OK to keep it there, but I was just wondering why this is happening.

It seems to me that the pin is staying in a state until something clears it. So, question is, is there something I can do to "clear" that pin status?

Thanks

strange "readPin" (void returns nothing)
You return the input parameter..
Study it once more.. carefully

It seems to me that the pin is staying in a state until something clears it. So, question is, is there something I can do to "clear" that pin status?

Certainly. Post ALL of your code. Explain what is connected to the pin. What mode is the pin in?

OK, I figured it out.

@pauls:
There is plenty of code there to assist. I so often see “send more code,” and when I do, I almost always get no further answers, so a bit burned out in asking a question and then playing the post-code game.

@knut_ny:
It was more pseudo code than actual as that is the guts of the section causing the issue. I was able to remove the delay with another line of code to clear the state.

There's a reason why I put braces {} on their own lines. Can you see what's missing below?

void setup() 
{
  pinMode(clickPin,INPUT_PULLUP);  // currently pin D10
  digitalWrite(clickPin,HIGH);
}

void readPin(uint8_t aVal) 
{
//  delay(200);  // See below why this is here
  boolean myClick = !digitalRead(clickPin);
  if (myClick) 
  {
    OK = true;
//    digitalWrite(clickPin,LOW);
//    digitalWrite(clickPin,HIGH);
    return aVal;
}

SalineSolution:

void readPin(uint8_t aVal) {

//  delay(200);  // See below why this is here
  boolean myClick = !digitalRead(clickPin);
  if (myClick) {
    OK = true;
//    digitalWrite(clickPin,LOW);
//    digitalWrite(clickPin,HIGH);
    return aVal;
}

This will not compile. It's pointless saying 'my code don't work' and then giving us code to look at that isn't the code that ain't working. It's like me taking my wife's car to the mechanic when mine is broken down.

It's like me taking my wife's car to the mechanic when mine is broken down.

And not telling them what needs to be fixed.