You are reading a single comment by @Radar and its replies. Click here to read the full conversation.
  • I've finally started playing with my Espruino, going through a few of the tutorials and trying a few things out.
    I'm having trouble replicating the BTN1 functionality on a external/extra button. I've connected a press button between pin C1 and 3.3v and my test code is

    function onInit() { 
    pinMode(C1, "input");
     }
    
     function buttonPressWatcher(e) {
        console.log("pressed!" + e.time); 
    }
    
    function buttonReleaseWatcher(e) {  
        console.log("Release!" + e.time); 
    }
    
    setWatch(buttonPressWatcher, C1, { repeat: true, edge: "rising", debounce:100}); 
    //setWatch(buttonReleaseWatcher, C1, { repeat: true, edge: "falling"}); 
    setWatch(buttonReleaseWatcher, C1, { repeat: true, edge: "falling", debounce:100}); 
    
    setWatch(buttonPressWatcher, BTN1, { repeat: true, edge: "rising", debounce:100});
    //setWatch(buttonReleaseWatcher, BTN1, { repeat: true, edge: "falling"}); 
    setWatch(buttonReleaseWatcher, BTN1, { repeat: true, edge: "falling", debounce:100});
    
    

    A press and release of BTN1 results in the logging of a press and release. A press of the button on C1 only results in the logging of the press.
    If I take the debounce parameter off the C1 setwatch command, I get a continual stream of "Release!" log messages.
    Any hints as to what I'm missing would be appreciated

About

Avatar for Radar @Radar started