Relay


Cylon Relay allows support for both Normally Open and Normally Closed relay boards.

For more information on relays click here.

How To Connect

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

  devices: {
    relay: { driver: 'relay', pin: 2, type: "closed" }
  }
});

How To Use

This example uses a relay with an arduino.

var Cylon = require('cylon');

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

  devices: {
    relay: { driver: 'relay', pin: 2, type: "closed" }
  },

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

Commands

turnOn

Turn the Relay on.

Params

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

Returns

  • (undefined)

turnOff

Turn the Relay off.

Params

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

Returns

  • (undefined)

toggle

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

Params

  • callback (Function) function to be invoked when done

Returns

  • (undefined)

Compatibility