software bounce for setwatch on puck

Posted on
  • Hi @Gordon,
    i need help on software debouncing a pin for setwatch.

    for ex, i have 2 pucks, in one puck i will have this code :-
    setWatch(senderase,D1, { edge:"rising",debounce:50, repeat: true });

    i want to debounce this pin in code in another puck, i will use NRF uart to send command.
    here is another puck code:-

    function send(cmd){
    NRF.requestDevice({ filters: [{ namePrefix: 'Puck.js' }] }).then(function(device) {
      require("ble_simple_uart").write(device,­ cmd, function() {
    print('Done!');
      });
    });
    }
    

    i tried with digitalpulse,but no use
    how to debounce that pin in first puck , any api is there?

    please help me to solve this issue

  • I'm not sure I understand the question...

    You want to send code to run on one Puck when a button on a second Puck is pressed?

    What you're doing looks fine, but maybe you could paste up the contents of the senderase function - it may be you're just not sending a newline character after the command

  • @Gordon .

    i will explain in this way.

    we have BTN or any pin, how to debounce that pin using code?

    puck 1 code:-
    setWatch(senderase,D1, { edge:"rising",debounce:50, repeat: true });

    senderase function called when the D1 is debounces right.

    puck2 code:-

    function send(cmd){
    NRF.requestDevice({ filters: [{ namePrefix: 'Puck.js' }] }).then(function(device) {
    require("ble_simple_uart").write(device,­ cmd, function() {
    print('Done!');
    });
    });
    }

    send("analogWrite(D1,1)\n");

    when i run this code, is this puck can debounce the D1 pin on puck1 ?
    if not any other api is there to that?

  • Sorry, I still don't understand...

    If you do:

    setWatch(senderase,D1, { edge:"rising",debounce:50, repeat: true });
    

    Then D1 will be debounced so senderase is not called unless D1 is high for at least 50ms.

    On puck2 I'm not sure what you're trying to do? That is basically the same as writing analogWrite(D1,1) directly onto puck1.

    In that case, since you're writing an analog value that is just 1, it's the same as digitalWrite(D1,1). It turns D1 into an output and sets it to 1 - which I guess will cause senderase to be called if D1 wasn't set previously - but since D1 is now an output it won't respond to external inputs any more

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

software bounce for setwatch on puck

Posted by Avatar for afrid @afrid

Actions