hybridgroup/cylon-intel-iot

View on GitHub
examples/led_brightness/led_brightness.js

Summary

Maintainability
A
1 hr
Test Coverage
"use strict";

var Cylon = require("cylon");

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

  devices: {
    led: { driver: "led", pin: 3 }
  },

  work: function(my) {
    var brightness = 0,
        fade = 5;

    every((0.05).seconds(), function() {
      brightness += fade;
      my.led.brightness(brightness);
      if ((brightness === 0) || (brightness === 255)) { fade = -fade; }
    });
  }
}).start();