Title: A small LEGO Mindstorms EV3 Node.js library
Slug: a-small-lego-mindstorms-ev3-node-js-library
Date: 2014-02-14 08:09:00
Author: Kartones
Lang: en
Tags: Development, Robotics, NodeJS, Javascript
Description: Creating a small library for LEGO Mindstorms EV3 using Javascript.

<p>I love <a href="http://en.wikipedia.org/wiki/Lego_Mindstorms">LEGO Mindstorms</a> since I knew of their existence in the early 2000s. I got all three of them: the RCX with a custom firmware to code it with C, NXT with a micro-JVM, and now the new EV3 with a Micro-SD card pending to be installed with a custom ARM Linux with Mono (for C#).</p>
<p>As I'm trying to push harder for Javascript in general as a cross-platform language, I decided instead to go for something different and harder, like coding the robot from Javascript. I came across Andrew Nesbitt's EV3 node library and decided to give it a try.</p>
<p>I had to switch the Bluetooth module as the original one didn't compiled under Windows * and most code looks as directly reverse engineered or captured from bluetooth communication, so I got into checking the EV3 operating system <a href="https://github.com/mindboards/ev3sources">source code</a> and decided to build my library almost from scratch to learn how the messages are send and received by the brick.</p>
<p>After pausing the idea with my recent job switch, I rushed this past days to be able to show something at the Freakend event last weekend, and now I have a quite small codebase for the library but at least organized and with most "obscure" code commented. The library only allows to connect, disconnect, play a tone or move the motors, but it is a good starting point.</p>
<p>I plan to at least implement support for the basic sensors that come with the EV3 and reading the state of the motors. I will <strong>not</strong> implement the whole OS library as I don't have so much spare time, but I do want to only code my brick with Javascript so eventually all basic functionality will be present.</p>
<p>Most interesting stuff of the official sources can be found at the <a href="https://github.com/mindboards/ev3sources/tree/master/lms2012/c_com/source">c_com library</a>; at least is what I'm using as guide for learning and building this lib.</p>
<p>You can find the library, along with a sample program that allows to move all four motors and play random beep tones with the keybord at <a href="https://github.com/Kartones/ev3-node">my GitHub</a>.</p>
<p> </p>
<p>* That's why I had my fight with Windows installing Node.js.</p>

<p>Update: Removed some dead links</p>
