Wire things up as shown in attached picture and use two no-repeat setWatch(...) on pin D1 initialized with pinMode(D1,"input_pullup") . Setup first watch with edge:"falling" to take the time with t0 = getTime() and setup of second watch with edge:"rising" with taking the time again ( t1 ) and re-setup first watch. Regarding the debounce time, you have to play a bit. In second watch you also calculate the difference of both times taken and show it somehow... for example by blinking as many seconds the button has been held. If it is a long time, you may use a green blinks for the tens of seconds and red blinks for the ones of seconds... ;-)
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.
@user140111
Wire things up as shown in attached picture and use two no-repeat
setWatch(...)
on pinD1
initialized withpinMode(D1,"input_pullup")
. Setup first watch withedge:"falling"
to take the time witht0 = getTime()
and setup of second watch withedge:"rising"
with taking the time again (t1
) and re-setup first watch. Regarding the debounce time, you have to play a bit. In second watch you also calculate the difference of both times taken and show it somehow... for example by blinking as many seconds the button has been held. If it is a long time, you may use a green blinks for the tens of seconds and red blinks for the ones of seconds... ;-)1 Attachment