You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • What you're doing there looks fine to me... You could try:

    setWatch(HomeUp, BTN, {repeat: true, edge:'falling', debounce:50});

    instead of

    setWatch(HomeUp, BTN, {repeat: true, edge:'falling'});

    I thought debounce on the button should have been automatic but maybe it's not... What can happen is the button actually physically bounces - effectively making two presses. Too fast for a human to see but the microcontroller picks it up.

    Having debounce:50 adds code that checks to ensure the button's been in that state for at least 50ms before calling your code.

    Or... what may be happening is you have the code saved twice somehow (once direct to flash, and once from save()) so you've got two setWatches. Try writing reset(1) on the left-hand side of the IDE and re-uploading your code (and if you're using direct to flash you don't need to call save() since it happens when you upload).

    Hope that helps!


Avatar for Gordon @Gordon started