provides a simple protocol to an embedded system! var firmata = require('firmata');! ! // Change this line to the serial port of a device! var modem = '/dev/cu.usbserial-DJ008CEA';! ! // Main part! var board = new firmata.Board(modem, function(err){! console.log('connected: ' + modem);! var ledOn = true;! ! // Configure pin 13 as output! board.pinMode(13, board.MODES.OUTPUT);! ! ! // Blink the LED! setInterval(function() {! ! if (ledOn) {! console.log('ON');! board.digitalWrite(13, board.HIGH);! } else {! console.log('OFF');! board.digitalWrite(13, board.LOW);! }! ! ledOn = !ledOn;! ! }, 500);! });!
five.Board();! ! board.on("ready", function() {! ! var led = new five.Led(13);! ! // "blink" the led in 500ms on-off phase periods! led.blink(500);! }); https://github.com/rwaldron/johnny-five/blob/master/eg/led-blink.js
0x18;! var wire = new i2c(address, {device: '/dev/i2c-1'}); // point to your i2c address, debug provides REPL interface ! ! wire.scan(function(err, data) {! // result contains an array of addresses ! });! ! wire.writeByte(byte, function(err) {});! ! wire.writeBytes(command, [byte0, byte1], function(err) {});! ! wire.readByte(function(err, res) { // result is single byte }) ! ! wire.readBytes(command, length, function(err, res) {! // result contains a buffer of bytes ! });! ! wire.on('data', function(data) {! // result for continuous stream contains data buffer, address, length, timestamp ! });!