Thank you!
Can you please explain the code? I am a bit confused with all the "pullups" =)
So we set a variable pulledUp to true and counter to zero.
Then every 10s we check.
I am confused with the else part - if we set pulledUp to false during "stuck LED" condition, then the first IF will get executed after 10 seconds, which will cause a reading update?
Should it not be other way around? I am confused =)
if (D2.read()) { // LED is off - all ok
onCount = 0;
pulledUp = FALSE;
} else {
onCount++;
if (onCount>6) { // >60 secs on
pulledUp = TRUE;
}
}
Also, what is the difference between
if (!pulledUp) pinMode(D2,"input_pullup");
in the beginning and
if (!pulledUp) pinMode(D2,"input");
in the end? Or the first one suppose to be true and the last one false?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Thank you!
Can you please explain the code? I am a bit confused with all the "pullups" =)
So we set a variable pulledUp to true and counter to zero.
Then every 10s we check.
I am confused with the else part - if we set pulledUp to false during "stuck LED" condition, then the first IF will get executed after 10 seconds, which will cause a reading update?
Should it not be other way around? I am confused =)
Also, what is the difference between
in the beginning and
in the end? Or the first one suppose to be true and the last one false?