Say what?

Would I like to know why this:

if (digitalRead(4) == LOW) {
doSomething();
}

Randomly triggers as if there’s some unseen demon child hammering a pushbutton on pin 4, however…

int btn;
btn=digitalRead(4);
if (btn == LOW) {
doSomething();
}

… Always works perfectly?

Yes. Yes I would.

image
Makes about as much sense as forgetting to trim those extraneously long terminal block pins.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.