Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed readme and added package.json

  • Loading branch information...
commit 0d8d95792859d3ad931df2d4ebf6ac79080182b0 1 parent 132eff0
Julian Gautier jgautier authored
Showing with 48 additions and 22 deletions.
  1. +47 −21 readme.md
  2. +1 −1  repl.js
68 readme.md
View
@@ -1,25 +1,51 @@
-#firmata.js
-A Node library to interact with an arduino running the firmata protocol.
-#Requirements
-Node
-Arduino running firmata (tested with v2.2)
-node-serialport https://github.com/voodootikigod/node-serialport
+#Firmata
+A Node library to interact with an Arduino running the firmata protocol.
+#Install
+ npm install -g firmata
+#Tests
+The tests are written with expresso and assume you have the async library install globally. It also assumes you have an Arduino Uno running firmata 2.2 with a photocell and an LED hooked up.
#Usage
- var firmata = require('..lib/firmata');
+ var firmata = require('firmata');
var board = new firmata.Board('path to usb',function(){
//arduino is ready to communicate
});
-View test folder for examples.
-#Methods:
-*board.digitalWrite(pin,value)*
- Write an output to a digital pin. pin is the number of the pin and the value is either board.HIGH or board.LOW
-
-*board.pinMode(pin,state)*
- Set a mode for a pin. pin is the number of the pin and state is one of the following. board.INPUT, board.OUTPUT, board.PWM
-
-*board.analogWrite(pin,value)*
- Write an output to a digital pin. pin is the number of the pin and the value is between 0 and 255.
-
-*board.analogRead(pin,callback)*
- Read an input for an analog pin. Every time there is data on the pin the callback will be fired.
-
+#REPL
+If you run *firmata* from the command line it will prompt you for the usb port. Then it will present you with a REPL with a board variable available.
+#The Board object:
+ #attributes
+ *Board.MODES*
+ {
+ INPUT:0x00,
+ OUTPUT:0x01,
+ ANALOG:0x02,
+ PWM:0x03,
+ SERVO:0x04
+ }
+ This is an enumeration of the different modes available. This are used in calls to the *pinMode* function.
+ *Board.HIGH* and *Board.LOW*
+ These are constants used to set a digital pin low or high. Used in calls to the *digitalWrite* function.
+ *Board.pins*
+ This is an array of all the pins on the arduino board.
+ Each value in the array is an object:
+ {
+ mode://current mode of pin which is on the the board.MODES.
+ ,value://current value of the pin. when pin is digital and set to output it will be Board.HIGH or Board.LOW. If the pin is an analog pin it will be an numeric value between 0 and 1023.
+ ,supportedModes://an array of modes from board.MODES that are supported on this pin.
+ ,analogChannel://will be 127 for digital pins and the pin number for analog pins.
+ }
+ This array holds all pins digital and analog. To get the analog pin number as seen on the arduino board use the analogChannel attribute.
+ *Board.analogPins*
+ This is an array of all the array indexes of the analog pins in the *Board.pins* array.
+ For example to get the analog pin 5 from the *Board.pins* attributes use:
+ board.pins[board.analogPins[5]]
+ #methods
+ *board.pinMode(pin,mode)*
+ Set a mode for a pin. pin is the number of the pin and the mode is on of the Board.MODES values.
+ *board.digitalWrite(pin,value)*
+ Write an output to a digital pin. pin is the number of the pin and the value is either board.HIGH or board.LOW.
+ *board.digitalRead(pin,callback)*
+ Read a digital value from the pin. Evertime there is data for the pin the callback will be fired with a value argument.
+ *board.analogWrite(pin,value)*
+ Write an output to a digital pin. pin is the number of the pin and the value is between 0 and 255.
+ *board.analogRead(pin,callback)*
+ Read an input for an analog pin. Every time there is data on the pin the callback will be fired with a value argument.
2  repl.js 100644 → 100755
View
@@ -1,3 +1,4 @@
+#!/usr/bin/env node
var firmata=require('./lib/firmata.js')
,repl = require('repl');
console.log('Enter USB Port and press enter:');
@@ -5,7 +6,6 @@ process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.once('data',function(chunk){
var port = chunk.replace('\n','');
- console.log('port');
var board = new firmata.Board(port,function(){
console.log('Successfully Connected to ')+port;
repl.start('firmata>').context.board=board;
Please sign in to comment.
Something went wrong with that request. Please try again.