You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • In http://www.espruino.com/BLE+IFTTT there's this code, which is what gets run on the Puck:

    connection.write("\x10setWatch(function(){Bluetooth.println('Pressed');},BTN,{repeat:true,debounce:50,edge:'rising'});\n",
    

    The gotcha you have is that the code on http://www.espruino.com/Puck.js#accelerometer-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):

    require("puckjsv2-accel-movement").on();
    var idleTimeout;
    Puck.on('accel',function(a) {
      LED.set();
      if (idleTimeout) clearTimeout(idleTimeout);
      else Bluetooth.println("Pressed");
      idleTimeout = setTimeout(function() {
        idleTimeout = undefined;
        LED.reset();
      },500);  
    });
    

    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
                connection.write("\x10setWatch(function(){Bluetooth.println('Pressed');},BTN,{repeat:true,debounce:50,edge:'rising'});\n",
                  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 :)

About

Avatar for Gordon @Gordon started