Use Octoblu to fly a NodeCopter drone!

Start by:

npm install ar-drone

Create a file called "index.js" with the following code:

var five = require('johnny-five'), led;
var meshblu = require('meshblu');

var conn = meshblu.createConnection({
    "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "token": "yyyyyyyyyyyyyyyyyyyyyyyy"
});

conn.on('ready', function(data){

    console.log("Connected to Meshblu");
    conn.on('message', function(databits){
        console.log(databits);
        data = JSON.parse(databits);

        if (data.payload.fly == "up") {
            client.takeoff();
        } else if (data.payload.fly == "down") {
            client.land();
        } else if (data.payload.fly == "stop") {
            client.stop();
        } else if (data.payload.fly == "spin") {
            client.clockwise(0.5);
        } else if (data.payload.fly == "flip") {
            client.animate('flipLeft', 1000);
        } else if (data.payload.red == "on") {
            client.animateLeds('blinkRed', 5, 2)
        } else if (data.payload.red == "off") {
            client.animateLeds('blinkRed', 0, 0)
        } else if (data.payload.green == "on") {
            client.animateLeds('blinkGreen', 5, 2)
        } else if (data.payload.green == "off") {
            client.animateLeds('blinkGreen', 0, 0)
        } else if (data.payload.demo == true) {
            client.takeoff();
            client
            .after(5000, function() {
                this.clockwise(0.5);
            })
            .after(3000, function() {
                this.stop();
                this.land();
            });
        }
    });
});

Open our JS Console. You can interact with your new Node.JS app by typing these commands in your browser's developer console:

// Fly demo! You can also send {"fly":"up"} or {"fly":"down"} or {"fly":"spin"} etc as the payload!
conn.message({
  "devices": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "payload": {"demo": true}
});