Coder Social home page Coder Social logo

ev3's Introduction

THIS PROJECT IS NO LONGER MAINTAINED by clebert.

ev3

[Deprecated] Node.js on the Lego Mindstorms EV3 Intelligent Brick.

Installation

$ npm install ev3

Usage

var ev3 = require('ev3');

Battery

ev3.battery.getVoltage() => number

var voltage = ev3.battery.getVoltage();

Button

ev3.button.[down | enter | escape | left | right | up] => EventEmitter

ev3.button.escape.on('press', function () {
    ...
});

ev3.button.escape.on('release', function () {
    ...
});

ev3.button.[down | enter | escape | left | right | up].isPressed() => boolean

var pressed = ev3.button.down.isPressed();

Motor

ev3.Motor.getSpeed(portName:string) => number

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');

ev3.Motor.getTachoCount(portName:string) => number

var tachoCountA = ev3.Motor.getTachoCount('A');
var tachoCountB = ev3.Motor.getTachoCount('B');
var tachoCountC = ev3.Motor.getTachoCount('C');
var tachoCountD = ev3.Motor.getTachoCount('D');

ev3.Motor(portNames:string) => Motor

var motor = new ev3.Motor('ABCD');
var motorAB = new ev3.Motor('AB');
var motorC = new ev3.Motor('C');

motor.resetTachoCount([callback:Function]) => void

motor.resetTachoCount(); // synchronous form

motor.resetTachoCount(function (error) {
    ...
}); // asynchronous form

motor.setPolarity(polarity:number[, callback:Function]) => void

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

motor.setPower(power:number[, callback:Function]) => void

Power: -100%..100%

motor.setPower(-100); // synchronous form

motor.setPower(-100, function (error) {
    ...
}); // asynchronous form

motor.setSpeed(speed:number[, callback:Function]) => void

Speed: -1000..1000 degrees per second

motor.setSpeed(-1000); // synchronous form

motor.setSpeed(-1000, function (error) {
    ...
}); // asynchronous form

motor.start([callback:Function]) => void

motor.start(); // synchronous form

motor.start(function (error) {
    ...
}); // asynchronous form

motor.stop([callback:Function]) => void

motor.stop(); // synchronous form

motor.stop(function (error) {
    ...
}); // asynchronous form

motor.stopAndBrake([callback:Function]) => void

motor.stopAndBrake(); // synchronous form

motor.stopAndBrake(function (error) {
    ...
}); // asynchronous form

Running tests

$ make test

Linting sources

$ make lint

License

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.