• so I am trying to understand when does it actually set pinmode, if the condition when everything is ok is setting it to false...

    Lets say the LED is off, and pulledUp==false... The flow of execution looks like this:

      // pulledUp==false, so pinMode(D2,"input_pullup"); is called
      if (!pulledUp) pinMode(D2,"input_pullup");
      // LED off, so D2.read() == true
      if (D2.read()) { // LED is off - all ok
        // we execute in here
        onCount = 0;
        pulledUp = true;
      } else {
        // not executed
      }
      // pulledUp is now true, so this is not executed
      if (!pulledUp) pinMode(D2,"input");
    

    So at the end of that, pulledUp==true, but pinMode(D2,"input_pullup"); was called at the start of the function

  • but what if LED is on (stuck)? So the loop that reads it every 10s sets pin pull up and then sets to input.
    I think I am missing the understanding of what input_pullup and input means.
    The confusion comes as I used to set pinmode to input_pullup before the setWatch

About

Avatar for Gordon @Gordon started