ev3dev-NodeJS
ev3dev-NodeJS is a nodejs module that lets you program your Lego EV3 brick with JavaScript. It uses a custom kernel called ev3dev, so it won't work with the out-of-the-box Lego kernel.
Although our goal is to support all of the functions of the EV3, we currently have implimented support for:
-
Motors
- Run forever
- Run for time
- Run servo/position
- LEDs
We also have experimental support for some sensors in the sensors branch.
Using motors
//Require the module
var ev3 = require('ev3dev');
//Create the motor on port A
var motorA = new ev3.Motor(ev3.MotorPort.A);
//Run the motor at 60% power for five seconds, and then hold it in place
motorA.startMotor({
targetSpeed: 60,
time: 5000,
stopMode: 'hold'
});
Using LEDs
//Require the module
var ev3 = require('ev3dev');
//Initialize both LEDs
var leftLED = new ev3.LED(ev3.ledPosition.left);
var rightLED = new ev3.LED(ev3.ledPosition.right);
//Set their color
leftLED.color = ev3.ledColorSetting.green;
rightLED.color = ev3.ledColorSetting.red;
Simple, right? Learn more about the Motor and LED APIs on the Wiki.