Getting Started - lyzadanger/johnny-five GitHub Wiki
Prerequisites
- At least an Arduino or compatible board (Uno, Mega, Leonardo, Fio, Pro, Pro Mini)
- Sparkfun Inventor's Kit (Recommended for getting started)
OSX
- Install Node.js 0.10.x
- Install Xcode
- Install node-gyp
npm install -g node-gyp
Windows
Via @ThomasDeutsch on https://github.com/rwldrn/johnny-five/issues/48#issuecomment-7696662
- Install Node.js 0.10.x 32 bit (unless anyone can confirm success with 64 bit)
- Install Visual Studio Express 2010 32 bit (make sure you have the C++ dependencies checked)
- Install Python 2.7.3
- Open up cmd (Start > Run.. > cmd) and enter
set PATH=%PATH%;C:\Python27
- Install node-gyp
npm install -g node-gyp
Hello World
Generally Arduino boards (Uno, Mega, Leonardo, Fio, Mini) come pre-flashed with the compiled StandardFirmata firmware. In most cases, getting started is as simple as...
mkdir nodebot && cd nodebot;
npm install johnny-five;
Now open your text editor and create a new file called "strobe.js", in that file type or paste the following:
var five = require("johnny-five"),
board = new five.Board();
board.on("ready", function() {
// Create an Led on pin 13
var led = new five.Led(13);
// Strobe the pin on/off, defaults to 100ms phases
led.strobe();
});
Make sure the board is plugged into your host machine (desktop, laptop, raspberry pi, etc). Now, in your terminal, type or paste the following:
node strobe.js
Trouble Shooting
-
If the above didn't work as expected, make sure that StandardFirmata is installed on the board:
- Download Arduino IDE
- Plug in your Arduino or Arduino compatible microcontroller via USB
- Open the Arduino IDE, select: File > Examples > Firmata > StandardFirmata
- Click the "Upload" button.
- If the upload was successful, the board is now prepared and you can close the Arduino IDE.
-
Sometimes Windows systems will fail to compile native dependencies, if you run across this case try:
npm install johnny-five --msvs_version=2012