• @Marc @dwallersv does the Pico look ok around where the button is? Maybe try cleaning around the sides of it with some board/contact cleaner and a small brush?

    The internal pullup resistor is around 40k, so I guess it's possible that if the contacts on the side of the button got dirty they'd get conductive and would start to pull the voltage on the input up - and then when you got your finger close, electrical noise might just be enough to set it off.

    @GeekBot The underlying hardware detects changes in the input, but not whether it is rising or falling. If the input changes state really fast it can go down to 0v, triggering the IRQ, but can then rise back up by the time the IRQ has fired so a 1 is read, and can then fall again. Espruino then thinks the button is in the raised state, and doesn't call your callback.

    There's actually very little that can be done about that internally... You could try adding a small capacitor across the button to stop it happening.

    Or one simple way might be to just detect the press, without a debounce?

    var ledjaunestate = false;
    var press = false;
    pinMode(B10, 'input_pullup');
    setWatch(function() {
      if (press) return;
      ledjaunestate = !ledjaunestate;
      digitalWrite(B1, ledjaunestate);
    }, B10, { repeat: true, edge: "both" });

Avatar for Gordon @Gordon started