valpinkman
1/5/2016 - 1:59 PM

cylon-example.js

const Cylon = require('cylon');

Cylon.robot({
  connections: {
    arduino: {
      adaptor: 'firmata',
      port: '/dev/cu.usbmodem1421'
    }
  },
  
  devices: {
    led: { driver: 'led', pin: 5 },
    pin: { driver: 'analog-sensor', pin: 4 }
  },

  work: function(robot) {
    robot.pin.analogRead();
    robot.pin.on('analogRead' value => {
      robot.led.brightness(Math.floor(value / 4));
    });  
  }

}).start();