Button


Simple interface that makes it possible to register clicks through physical input.

For more information click here.

How To Connect

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

  devices: {
    button: { driver: 'button', pin: 2 }
  },
});

How To Use

This example detects when a button has been pushed.

var Cylon = require('cylon');

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

  devices: {
    button: { driver: 'button', pin: 2 }
  },

  work: function(my) {
    my.button.on('push', function() {
      console.log("Button pushed!");
    });
  }
}).start();

Commands

isPressed

Check whether or not the Button is currently pressed

Params

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

Returns

  • (Boolean) whether or not the button is pressed

Events

push

Emitted when the Button is pushed


release

Emitted when the Button is released

Circuit

Compatibility