LED


Allows user to interact with LEDs through digital output and PWM (Pulse Width Modulation)

For more information click here.

How To Connect

Cylon.robot({
  connections: {
    arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
  },

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

How To Use

This example turns an LED on and off.

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
  },

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

  work: function(my) {
    every((1).second(), function() {
      my.led.toggle();
    });
  }
}).start();

Commands

turnOn

Writes a HIGH (1) value to the pin, turning the LED on.

Also sets this.isHigh to true.

Params

  • [callback] (Function) - (err, val) triggers when write is complete

Returns

  • (undefined)

turnOff

Writes a LOW (0) value to the pin, turning the LED off.

Also sets this.isHigh to false.

Params

  • [callback] (Function) - (err, val) triggers when write is complete

Returns

  • (undefined)

toggle

Toggles the LED on or off, depending on its current state

Params

  • callback (Function) function to be invoked when done

Returns

  • (undefined)

currentBrightness

Returns the current brightness of the LED.

Params

  • [callback] (Function) invoked with err, value as args

Returns

  • (Number) the current LED brightness value (0-255)

brightness

Sets brightness of the LED to the specified value using PWM.

Params

  • value (Number) - PWM value to set the brightness to (0-255)

  • [callback] (Function) - (err, val) triggers when write is complete

Returns

  • (undefined)

isOn

Returns whether or not the LED is currently on

Params

  • [callback] (Function) invoked with err, value as args

Returns

  • (Boolean) whether or not the LED is currently on

Circuit

Compatibility