• Hey all,

    Brand new to Puck.js and enjoying playing around with it so far.

    I'm trying to put a simple node script together that can detect the Puck's button press so I can run a couple of things on each press. I'm having a bit of trouble figuring out where to start, however.

    I'm guessing that the best way to do this would be over a Bluetooth connection, but I'm having trouble finding the relevant docs or any examples to help get this started.

    If anyone's got any advice it would be greatly appreciated.

    Cheers!

  • Hi,

    There are a few ways to go from Puck.js to Node.js. The easy one is just to use the HID support to get it to act like a key on the keyboard is physically pressed and detect that - but I think you might have tried that already?

    The other nice method is to use advertising - Puck.js will send advertising data with information about the button press, and you just need to receive that.

    @knolleary posted up his code for that here that's really nice: http://forum.espruino.com/conversations/298279/#13404185

    And I'd advise that you try using that to get started - it provides a really useful way to send arbitrary data.

  • Hey again Gordon,

    That looks perfect, I'll give it a try!

    After your advice on my GitHub issue yesterday I did look into using Puck.js as a HID and that seemed like it could work well, but the advertising example looks like a cleaner way to approach it to me.

    If it works out I'll throw together a short blog post on it, as I spent a good few hours searching for examples on how others had approached this problem and couldn't find anything that didn't involve Node-RED.

    Thanks again for taking the time!

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

Detect Puck button press on external device, ideally within node script

Posted by Avatar for joshfarrant @joshfarrant

Actions