THIS PROJECT IS NO LONGER MAINTAINED by clebert.
[Deprecated] Node.js on the Lego Mindstorms EV3 Intelligent Brick.
$ npm install ev3
var ev3 = require('ev3');
var voltage = ev3.battery.getVoltage();
ev3.button.escape.on('press', function () {
...
});
ev3.button.escape.on('release', function () {
...
});
var pressed = ev3.button.down.isPressed();
Returns the speed in degrees per second.
var speedA = ev3.Motor.getSpeed('A');
var speedB = ev3.Motor.getSpeed('B');
var speedC = ev3.Motor.getSpeed('C');
var speedD = ev3.Motor.getSpeed('D');
var tachoCountA = ev3.Motor.getTachoCount('A');
var tachoCountB = ev3.Motor.getTachoCount('B');
var tachoCountC = ev3.Motor.getTachoCount('C');
var tachoCountD = ev3.Motor.getTachoCount('D');
var motor = new ev3.Motor('ABCD');
var motorAB = new ev3.Motor('AB');
var motorC = new ev3.Motor('C');
motor.resetTachoCount(); // synchronous form
motor.resetTachoCount(function (error) {
...
}); // asynchronous form
Polarity:
- -1 makes the motor run backward
- 1 makes the motor run forward
- 0 makes the motor run in the opposite direction
motor.setPolarity(-1); // synchronous form
motor.setPolarity(-1, function (error) {
...
}); // asynchronous form
Power: -100%..100%
motor.setPower(-100); // synchronous form
motor.setPower(-100, function (error) {
...
}); // asynchronous form
Speed: -1000..1000 degrees per second
motor.setSpeed(-1000); // synchronous form
motor.setSpeed(-1000, function (error) {
...
}); // asynchronous form
motor.start(); // synchronous form
motor.start(function (error) {
...
}); // asynchronous form
motor.stop(); // synchronous form
motor.stop(function (error) {
...
}); // asynchronous form
motor.stopAndBrake(); // synchronous form
motor.stopAndBrake(function (error) {
...
}); // asynchronous form
$ make test
$ make lint
The MIT License (MIT)
Copyright (c) 2013 Clemens Akens (http://clebert.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.