How to use cylon - 10 common examples

To help you get started, we’ve selected a few cylon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / connectthedots / Devices / DirectlyConnectedDevices / NodeJS / IntelEdisonSensorTag / inteledisonsensortagctd.js View on Github external
var connect_the_dots = function()
{
    console.log("Device Ready to connect its dots");
    // ---------------------------------------------------------------
    // Initialization of the Cylon object
    Cylon.robot( {
        connections: {
            edison: { adaptor: 'intel-iot' }
        },
        
        devices: {
            led: { driver: 'led', pin: 13 }
        },
        
        work: function (my) {
            
            // Every second, try and connect to a SensorTag. Toggle Led when discovering. Keep led on when connected
            every((1).second(), function () {

                if (!SensorTagConnected && !DiscoveringSensorTag) {
                    console.log('Discovering sensortag...');
                    DiscoveringSensorTag = true;
github Azure / connectthedots / Devices / DirectlyConnectedDevices / NodeJS / IntelEdison / ConnectTheDotsEdison.js View on Github external
res.on('data', function (d) {
            process.stdout.write(d);
        });
    });
        
    req.on('error', function (e) {
        console.error(e);
    });
        
    req.write(message);
        
    req.end();
}

// Initialization of the Cylon object to get Weather shield data every second
Cylon.robot( {
    connections: {
        edison: { adaptor: 'intel-iot' }
    },
    
    devices: {
        led: { driver: 'led', pin: 13 },
        shield_blue_led: { driver: 'led', pin: 7 },
        mpl115a2: { driver: 'mpl115a2' }
    },
    
    work: function (my) {
        // Regenerate the SAS token every hour
        every((3600000).second(), function () {
            my_sas = create_sas_token(my_uri, settings.keyname, settings.key);
        });
github hybridgroup / cylon-speech / examples / speech.js View on Github external
var Cylon = require('cylon');

Cylon.robot({
  // voice for espeak can be specified either in one string or as params for the adaptor.
  // both connections below will reproduce with the same voice.
  // connection: { name: 'speech', adaptor: 'speech', language: 'en, gender: 'f', 'voice: '1' },
  // speed: number of words per minute.
  connection: { name: 'speech', adaptor: 'speech', voice: 'en-f3', speed: 120 },
  device: {name: 'mouth', driver: 'speech'},

  work: function(my) {
    my.mouth.say("This is awesome!");
    my.mouth.say("I'm a Cylon.JS robot, and I'm talking!");
  }
}).start();
github acltc / robots / sphero / basic.js View on Github external
var Cylon = require('cylon');

Cylon.robot({
  connections: [{ name: 'sphero', adaptor: 'sphero', port: '/dev/tty.Sphero-WWB-AMP-SPP' }], // change this port to whatever your settings are
  devices: [{ name: 'sphero', driver: 'sphero' }],

  work: function(my) {
    every((1).second(), function() {
      my.sphero.roll(60, Math.floor(Math.random() * 360));
    });
  }
}).start();
github Losant / losant-mqtt-js / examples / edison-range-finder.js View on Github external
var Structure = require('../index');
var Cylon = require('cylon');


// Initialize the Structure Gateway with your account information.
var gateway = Structure.gateway({
  key: 'my-structure-key',
  secret: 'my-structure-secret',
  gatewayId: 'my-structure-gateway-id',
  deviceIds: [ 'my-device-id' ]
});

// This example uses the Cylon module to interface with the Edison hardware.
// This example is assuming an analog input is plugged in to pin A0.
var robot = Cylon.robot({

  connections: {
    edison: { adaptor: 'intel-iot' }
  },

  devices: {
    range: { driver: 'analog-sensor', pin: 0 }, // range sensor plugged into A0.
  },

  work: function(my) {

    // Get the device object from the gateway.
    var range = gateway.devices['my-device-id'];

    // Ready the analog value from the edison and send it to structure.
    // Structure receives state information as an object with attributes
github noderockets / noderocket-rocket / pirocket-advanced.js View on Github external
dataInterval: 100,
    mode: 1,
    servoInitAngle: 150,
    servoReleaseAngle: 65,
    launchThreshold: 3
  }, opts);

  var thiz = this;
  //var altBuffer = [];

  var data = {
    launched: false,
    deployed: false
  };

  var robot = Cylon.robot({
    connection: {name: 'raspi', adaptor: 'raspi'},
    devices: [
      { name: 'bmp180',   driver: 'bmp180' },
      { name: 'servo',    driver: 'servo',  pin: 12 },
      { name: 'statusLed', driver: 'led',    pin: 15 },
      { name: 'statusLed2', driver: 'led',    pin: 18 },
      { name: 'btn1', driver: 'button',    pin: 11 },
      { name: 'btn2', driver: 'button',    pin: 16 }
    ],

    work: function(my) {
      my.statusLed.turnOn();

      my.btn1.on('push', function() {
        //console.log('BUTTON 1 PUSHED');
        thiz.emit('btn1-pushed');
github hybridgroup / cylon-octoblu / examples / blink / fluent-blink.js View on Github external
"use strict";

var Cylon = require("cylon");

Cylon
  .robot()
  .connection("arduino", { adaptor: "firmata", port: "/dev/tty.usbmodem1411" })
  .connection("octoblu", {
    adaptor: "octoblu",
    uuid: "SKYNET_UUID",
    token: "SKYNET_TOKEN"
  })
  .device("led", { driver: "led", pin: 13, connection: "arduino" })
  .on("ready", function(bot) {
    console.log("connected...");

    bot.octoblu.on("message", function(data) {
      console.log(data);

      if (data.payload.red === "on") {
        bot.led.turnOn();
github hybridgroup / cylon-intel-iot / examples / groverelay / fluent-groverelay.js View on Github external
"use strict";

var Cylon = require("cylon");

Cylon
  .robot()
  .connection("edison", { adaptor: "intel-iot" })
  .device("relay", {
    driver: "upm-groverelay",
    pin: 4
  })

  .on("ready", function(bot) {
    setInterval(function() {
      if (bot.relay.isOff()) {
        bot.relay.turnOn();
        console.log("on");
      } else {
        bot.relay.turnOff();
        console.log("off");
      }
github hybridgroup / cylon-pebble / examples / hello_pebble / hello-pebble-fluent-style.js View on Github external
var cylon = require('cylon');

cylon.config({
  api: {
    host: '0.0.0.0',
    port: '8080',
    ssl:  false
  }
});

cylon.api();

cylon.robot({
  name: 'pebble',

  connection: { name: 'pebble', adaptor: 'pebble' },
  device: { name: 'pebble', driver: 'pebble' }
})

.on('ready', function(robot) {
  robot.pebble.send_notification("Hello Pebble!");

  robot.pebble.on('button', function(data) {
    console.log("Button pushed:", data);
  });

  robot.pebble.on('tap', function(data) {
    console.log("Tap event detected:", data);
  });
github hybridgroup / cylon-beaglebone / examples / analog_sensor / analog-sensor-with-led-fluent-style.js View on Github external
var cylon = require('cylon');

cylon.robot({
  connection: { name: 'beaglbone', adaptor: 'beaglebone' },
  devices: {
    sensor: { driver: 'analogSensor', pin: "P9_33" },
    led: { driver: 'led', pin: "P9_14" },
  }
})

.on('ready', function(robot) {
  var brightness = 0;
  setInterval(function() {
    brightness = robot.sensor.analogRead().fromScale(0, 1799).toScale(0, 255) | 0;
    console.log('brightness => ', brightness);
    robot.led.brightness(brightness);
  }, 100);
})

cylon

JavaScript framework for robotics, drones, and the Internet of Things (IoT) using Node.js

Apache-2.0
Latest version published 9 years ago

Package Health Score

60 / 100
Full package analysis

Popular cylon functions