Newbie to Puck.js - Movement to IFTTT

Posted on
  • Hey community. Quick question for you. I just received a puck.js in the mail, and I've been playing around with it, but I can't figure something out.

    I've done the "Bluetooth LE and If This Then That" tutorial, where if you press a button, it triggers your IFTTT applet, but I'm trying to code if the puck moves instead of pushing the button.

    Can anyone help me out? Thank you!

  • In there's this code, which is what gets run on the Puck:


    The gotcha you have is that the code on­meter-gyro uses a library, which won't get uploaded if you copy/paste that code. So what I'd say is, open the Web IDE and upload this code to the Puck (to Flash):

    var idleTimeout;
    Puck.on('accel',function(a) {
      if (idleTimeout) clearTimeout(idleTimeout);
      else Bluetooth.println("Pressed");
      idleTimeout = setTimeout(function() {
        idleTimeout = undefined;

    And then delete all this code from the IFTTT example:

    connection.write("\x10reset();\n", function() {
              // Wait for it to reset itself
              setTimeout(function() {
                // Now tell it to write data on the current light level to Bluetooth 10 times a second
                  function() { log("Ready!"); });
              }, 1500);

    You don't need any of that code any more because you've just manually loaded the code onto the Puck. Now you should be sorted :)

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

Newbie to Puck.js - Movement to IFTTT

Posted by Avatar for JasonD @JasonD