diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..5edbec6 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +# Authors ordered by first contribution. + +Tobias Schneider +Chris Williams diff --git a/README b/README index e69de29..a577d72 100644 --- a/README +++ b/README @@ -0,0 +1,34 @@ +Version: 0.2.3 - Released March 20, 2011 + +***** + +This package is designed to allow you to control and program an arduino chipset with JavaScript. It leverages the node-serialport code base, so ensure that you have that installed. In order to see what this package can do, please watch [this presentation from JSConf EU 2010](http://jsconf.eu/2010/speaker/livingroombindmotion_function.html) by [Nikolai Onken](http://twitter.com/nonken) and [Jörn Zaefferer](http://bassistance.de/). + +***** + +How To Use +========== + +Using node-arduino is pretty easy because it is pretty basic. It is essentially a wrapper with arduino specific message handling around the node-serialport library. + +To Install +---------- + +
+  npm install serialport arduino
+
+ +To Use +------ + +Opening an arduino board: + +
+  var arduino = require("arduino");
+  var myBoard = arduino.connect("/dev/tty-usbserial1");
+
+ +Alpha +----- + +This code is still very much alpha and early stage, but that just makes it more fun to work with. If you find an issue/problem, fork it and issue a pull request. No matter what, enjoy and do cool things with this code. \ No newline at end of file diff --git a/deps/node-serialport b/deps/node-serialport deleted file mode 160000 index 6e4d76b..0000000 --- a/deps/node-serialport +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6e4d76b7f097b237bbd96e92e64b6dd0e588b56f diff --git a/lib/arduino.js b/lib/arduino.js index ddd64f0..a05e91d 100644 --- a/lib/arduino.js +++ b/lib/arduino.js @@ -6,7 +6,7 @@ */ var sys = require('sys') - , SerialPort = require('../deps/node-serialport/serialport').SerialPort + , SerialPort = require('serialport').SerialPort ; const SERIAL_BAUDRATE = 9600; @@ -32,7 +32,7 @@ exports.DEFAULT = 0x01; exports.INTERNAL = 0x03; Board = function (path) { - this.sp = new SerialPort(path, SERIAL_BAUDRATE); + this.sp = new SerialPort(path, {baudrate: SERIAL_BAUDRATE}); } Board.prototype = { @@ -40,25 +40,30 @@ Board.prototype = { this.sp.write(new Buffer([OPC_PIN_MODE, pin, mode]), 3); } -, digitalRead : function (pin) { - // TODO - } + , digitalRead : function (pin) { + // TODO + } -, digitalWrite : function (pin, val) { - this.sp.write(new Buffer([OPC_DIGITAL_WRITE, pin, val]), 3); - } + , digitalWrite : function (pin, val) { + this.sp.write(new Buffer([OPC_DIGITAL_WRITE, pin, val]), 3); + } -, analogReference : function (type) { - this.sp.write(new Buffer([OPC_ANALOG_REFERENCE, type]), 2); - } + , analogReference : function (type) { + this.sp.write(new Buffer([OPC_ANALOG_REFERENCE, type]), 2); + } -, analogRead : function (pin) { - // TODO - } + , analogRead : function (pin) { + // TODO + } -, analogWrite : function (pin, val) { + , analogWrite : function (pin, val) { this.sp.write(new Buffer([OPC_ANALOG_WRITE, pin, val]), 3); + }, + + close: function () { + this.sp.close() } + }; exports.connect = function (path) { diff --git a/package.json b/package.json new file mode 100644 index 0000000..f229eaf --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ "name" : "arduino", + "version" : "0.2.3", + "description" : "Control your Arduino with Node", + "author": "Tobias Schneider ", + "main": "./lib/arduino", + "contributors": [ + { "name": "Tobias Schneider", "email": "schneider@uxebu.com" }, + { "name": "Chris Williams", "email": "voodootikigod@gmail.com" } + ], + "repository": { + "type": "git", + "url": "https://github.com/voodootikigod/node-arduino.git" + }, "dependencies": { + "serialport": ">= 0.2.2" + }, + "keywords": ["arduino", "serialport", "robots"], + "repository": { + "type": "git", + "url": "https://github.com/voodootikigod/node-arduino.git" + }, + "engines": { "node": ">= 0.4.1 < 0.5.0" } +}