The ESCs class constructs a collection object containing multiple ESC objects. Any method called on an ESCs object will be called on each member of the ESCs object with the same parameters.

See also:

Parameters

  • numsOrObjects An array of pins, ESC parameter objects and/or ESC objects:

    PropertyTypeValue/ DescriptionDefaultRequired
    numsOrObjectsArrayAn element for each ESC. Any valid ESC parameters will workyes

Component Initialization

###With Pins

// Create two basic ESCs
//
new five.ESCs([9, 10]);

###With Objects

// Create two ESCs
//
new five.ESCs([{
  pin: 9
}, {
  pin: 10
}]);

Usage

Control all members simultaneously:

var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

  var escs = new five.ESCs([3, 5]);

  // Set all ESCs to max.
  escs.throttle(100);
});

ESCs

Control a single ESC in an ESCs instance:

var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

  var escs = new five.ESCs([9, 10]);

  // Set the ESC on pin 9 to 90% of max speed.
  escs[0].throttle(90);
});

Using multiple controllers in a single ESCs instance:

var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

  var escs = new five.ESCs([
    { controller: "PCA9685", pin: 0 }, // Attached to an Adafruit PWM shield
    { pin: 3 } // Attached directly to the Arduino
  ]);

  // Set both escs to 75% of max speed.
  escs.throttle(75);
});

Two Controllers

Using ESC objects in ESCs:

var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

  var escA = new five.ESC(9);
  var escB = new five.ESC(10);

var motors = new five.ESCs([escA, escB]);

  // Set ESCs independently
  escA.throttle(20);
  escB.throttle(90);

  // Set all ESCs to max speed.
  escs.throttle(100);

});

API

All methods and properties in the ESC API are available on ESCs

Events

Events are emitted on the individual ESC objects so listeners must be attached there. See ESC events

0

Hi! The Johnny-Five community is building new projects every day. We made this newsletter to tell you about what's new, what's good, and what's next for Open Source robotics. Join us in exploring what we can make together.

Fork me on GitHub