Connect physical world to the Internet with JavaScript

Andrey Kucherenko

Maxim Kryachko

Что?
Зачем?
Как?

Что?

Зачем?

Как?

Hardware platforms

Software frameworks

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    edison: { adaptor: 'intel-iot' }
  },

  devices: {
    led: { driver: 'led', pin: 13 }
  },

  work: function(my) {
    every((1).second(), my.led.toggle);
  }
}).start();
var Cylon = require('cylon');
Cylon.robot({

    connections: {
        edison: {adaptor: 'intel-iot'},
        sphero: {adaptor: 'sphero', port: "/dev/rfcomm0"}
    },

    devices: {
        sphero: {driver: 'sphero', connection: 'sphero'}
    },

    work: function (my) {
        var color = process.argv[2] || 0xFF0000;

        my.sphero.color(color);
     
    }
});
Cylon.start();
var Cylon = require('cylon');

Cylon.robot({
  connections: {
    edison: { adaptor: 'intel-iot'},
    sphero: { adaptor: 'sphero', port: '/dev/rfcomm0' }
  },

  devices: {
    led: { driver: 'led', pin: 13, connection: 'edison' },
    sphero: { driver: 'sphero', connection: 'sphero' }
  },

  work: function(my) {
    my.sphero.stop();
    my.sphero.detectCollisions();
    my.sphero.on('collision', function() {
      my.led.toggle();
    });
  }
}).start();
var Cylon = require('cylon');

Cylon.robot({
  connections: {
    sphero: { adaptor: 'sphero', port: '/dev/rfcomm0' }
  },

  devices: {
    sphero: { driver: 'sphero' }
  },

  work: function(my) {
    var flag = true;
    var color = 0x00FF00,
        bitFilter = 0xFFFF00;

    console.log("Setting up Collision Detection...");

    my.sphero.on("collision", function() {
      console.log("Collision:");
      color = color ^ bitFilter;
      console.log("Color: " + (color.toString(16)) + " ");
      my.sphero.color(color);
    });

    my.sphero.detectCollisions();    

    every((2).second(), function () {
     my.sphero.roll(60, flag ? 190 : 10);
     flag = !flag;
    });
  }
}).start();

Parrot Bebop

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    bebop: { adaptor: 'bebop' }
  },

  devices: {
    drone: { driver: 'bebop' }
  },

  work: function(my) {
    my.drone.takeOff();
    after((5).seconds(), my.drone.land);
  }
}).start();
var arDrone = require('ar-drone');
var client  = arDrone.createClient();
client.createRepl();


$ node repl.js
// Make the drone takeoff
drone> takeoff()
true
// Wait for the drone to takeoff
drone> clockwise(0.5)
0.5
// Let the drone spin for a while
drone> land()
true
// Wait for the drone to land

Вопросы?

Connect physical world to the Internet with JavaScript

By Andrey Kucherenko

Connect physical world to the Internet with JavaScript

IoT presentation for OdessaJS 2015 conference

  • 2,098
Loading comments...

More from Andrey Kucherenko