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).
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.
What you're doing there looks fine to me... You could try:
instead of
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 twosetWatches
. Try writingreset(1)
on the left-hand side of the IDE and re-uploading your code (and if you're usingdirect to flash
you don't need to callsave()
since it happens when you upload).Hope that helps!