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?
@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.
// 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.