• Actually yes, I guess you could remove the pullup if it's on for too long.

    So maybe some additional code:

    var onCount = 0;
    var pulledUp = true;
    setInterval(function() { // every 10 seconds
      if (!pulledUp) pinMode(D2,"input_pullup");
      if (D2.read()) { // LED is off - all ok
        onCount = 0;
        pulledUp = true;
      } else {
        onCount++;
        if (onCount>6) { // >60 secs on
          pulledUp = false;
        }
      }
      if (!pulledUp) pinMode(D2,"input");
    }, 10000);
    
    //And then in your setWatch
    setWatch(function(e) {
      if (!pulledUp) return;
      //...
    
About

Avatar for Gordon @Gordon started