Motor


Provides motor manipulation tools for Cylon.js like on/off, speed modulation using PWM, use of bidirectional motors using forward/backward pins.

For more information click here.

How To Connect

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

  devices: {
    motor: { driver: 'motor', pin: 3 }
  },

});

How To Use

var Cylon = require('cylon');

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

  devices: {
    motor: { driver: 'motor', pin: 3 }
  },

  work: function(my) {
    my.motor.speed(100);

    after((5).seconds(), function() {
      my.motor.stop();
    });
  }
}).start();

Commands

turnOn

Turns the Motor on by writing a HIGH (1) value to the pin

Also sets this.isOn to true.

Params

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

Returns

  • (undefined)

turnOff

Turns the Motor off by writing a LOW (0) value to the pin

Also sets this.isOn to false.

Params

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

Returns

  • (undefined)

toggle

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

Params

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

Returns

  • (undefined)

currentSpeed

Returns the Motor's current speed value

Params

  • [callback] (Function) - (err, val)

Returns

  • (Number) the current motor speed

speed

Sets the Motor's speed to the PWM value provided (0-255)

Params

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

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

Returns

  • (undefined)

Circuit

Compatibility