Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 113 lines (80 sloc) 4.537 kb
0d8d957 Julian Gautier changed readme and added package.json
jgautier authored
1 #Firmata
2 A Node library to interact with an Arduino running the firmata protocol.
3 #Install
4 npm install -g firmata
5 #Tests
6 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.
4b03e4b Julian Gautier removed extra console.logs
jgautier authored
7 #Usage
764f3ca Julian Gautier trying fix code block
jgautier authored
8
0d8d957 Julian Gautier changed readme and added package.json
jgautier authored
9 var firmata = require('firmata');
4b03e4b Julian Gautier removed extra console.logs
jgautier authored
10 var board = new firmata.Board('path to usb',function(){
11 //arduino is ready to communicate
8e98828 Julian Gautier fixed formatting
jgautier authored
12 });
0d8d957 Julian Gautier changed readme and added package.json
jgautier authored
13 #REPL
14 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.
0cf3e45 Julian Gautier Edited readme.md via GitHub
jgautier authored
15 #Board
16 The Board object is where all the functionality is for the library.
5467ba5 Julian Gautier Edited readme.md via GitHub
jgautier authored
17 ##attributes
4c9f935 Julian Gautier Edited readme.md via GitHub
jgautier authored
18 *Board.MODES*
764f3ca Julian Gautier trying fix code block
jgautier authored
19
0cf3e45 Julian Gautier Edited readme.md via GitHub
jgautier authored
20 {
21 INPUT:0x00,
22 OUTPUT:0x01,
23 ANALOG:0x02,
24 PWM:0x03,
25 SERVO:0x04
26 }
8544541 Julian Gautier trying fix code block
jgautier authored
27 This is an enumeration of the different modes available. This are used in calls to the *pinMode* function.
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
28
8544541 Julian Gautier trying fix code block
jgautier authored
29 *Board.HIGH* and *Board.LOW*
772a558 Julian Gautier Edited readme.md via GitHub
jgautier authored
30
8544541 Julian Gautier trying fix code block
jgautier authored
31 These are constants used to set a digital pin low or high. Used in calls to the *digitalWrite* function.
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
32
8544541 Julian Gautier trying fix code block
jgautier authored
33 *Board.pins*
772a558 Julian Gautier Edited readme.md via GitHub
jgautier authored
34
8544541 Julian Gautier trying fix code block
jgautier authored
35 This is an array of all the pins on the arduino board.
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
36
8544541 Julian Gautier trying fix code block
jgautier authored
37 Each value in the array is an object:
38
39 {
40 mode://current mode of pin which is on the the board.MODES.
41 ,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.
42 ,supportedModes://an array of modes from board.MODES that are supported on this pin.
43 ,analogChannel://will be 127 for digital pins and the pin number for analog pins.
44 }
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
45
8544541 Julian Gautier trying fix code block
jgautier authored
46 This array holds all pins digital and analog. To get the analog pin number as seen on the arduino board use the analogChannel attribute.
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
47
8544541 Julian Gautier trying fix code block
jgautier authored
48 *Board.analogPins*
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
49
8544541 Julian Gautier trying fix code block
jgautier authored
50 This is an array of all the array indexes of the analog pins in the *Board.pins* array.
51 For example to get the analog pin 5 from the *Board.pins* attributes use:
52
53 board.pins[board.analogPins[5]];
895e946 Julian Gautier Edited readme.md via GitHub
jgautier authored
54 ##methods
265c3ac Julian Gautier changed formatting
jgautier authored
55 board.pinMode(pin,mode)
a1b3c5a Julian Gautier Edited readme.md via GitHub
jgautier authored
56
46f5c29 Julian Gautier Edited readme.md via GitHub
jgautier authored
57 Set a mode for a pin. pin is the number of the pin and the mode is on of the Board.MODES values.
a1b3c5a Julian Gautier Edited readme.md via GitHub
jgautier authored
58
265c3ac Julian Gautier changed formatting
jgautier authored
59 board.digitalWrite(pin,value)
a1b3c5a Julian Gautier Edited readme.md via GitHub
jgautier authored
60
46f5c29 Julian Gautier Edited readme.md via GitHub
jgautier authored
61 Write an output to a digital pin. pin is the number of the pin and the value is either board.HGH or board.LOW.
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
62
265c3ac Julian Gautier changed formatting
jgautier authored
63 board.digitalRead(pin,callback)
a1b3c5a Julian Gautier Edited readme.md via GitHub
jgautier authored
64
46f5c29 Julian Gautier Edited readme.md via GitHub
jgautier authored
65 Read a digital value from the pin. Evertime there is data for the pin the callback will be fired with a value argument.
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
66
265c3ac Julian Gautier changed formatting
jgautier authored
67 board.analogWrite(pin,value)
a1b3c5a Julian Gautier Edited readme.md via GitHub
jgautier authored
68
46f5c29 Julian Gautier Edited readme.md via GitHub
jgautier authored
69 Write an output to a digital pin. pin is the number of the pin and the value is between 0 and 255.
dca2597 Julian Gautier Edited readme.md via GitHub
jgautier authored
70
265c3ac Julian Gautier changed formatting
jgautier authored
71 board.analogRead(pin,callback)
a1b3c5a Julian Gautier Edited readme.md via GitHub
jgautier authored
72
f4a0e1b Julian Gautier added documentation"
jgautier authored
73 Read an input for an analog pin. Every time there is data on the pin the callback will be fired with a value argument.
74
265c3ac Julian Gautier changed formatting
jgautier authored
75 board.servoWrite(pin,degree)
9251ce3 Julian Gautier committing i2c updates, examples and read me change
jgautier authored
76 Set I2C Config on the arduino
77
78 board.sendI2CConfig(delay)
f4a0e1b Julian Gautier added documentation"
jgautier authored
79
80 Write a degree value to a servo pin.
81
265c3ac Julian Gautier changed formatting
jgautier authored
82 board.sendI2CWriteRequest(slaveAddress,[bytes])
f4a0e1b Julian Gautier added documentation"
jgautier authored
83
84 Write an array of bytes to a an I2C device.
85
265c3ac Julian Gautier changed formatting
jgautier authored
86 board.sendI2CReadRequest(slaveAddress,numBytes,function(data))
f4a0e1b Julian Gautier added documentation"
jgautier authored
87
88 Requests a number of bytes from a slave I2C device. When the bytes are received from the I2C device the callback is called with the byte array.
9251ce3 Julian Gautier committing i2c updates, examples and read me change
jgautier authored
89 *note* You must use the latest version of firmata seen here http://firmata.svn.sourceforge.net/viewvc/firmata/arduino/trunk/Firmata/examples/StandardFirmata/ for I2C Support.
5e439fe Julian Gautier refactored code and added JSDoc comments
jgautier authored
90 ## License
91
92 (The MIT License)
93
94 Copyright (c) 2011 Julian Gautier <julian.gautier@alumni.neumont.edu>
95
96 Permission is hereby granted, free of charge, to any person obtaining
97 a copy of this software and associated documentation files (the
98 'Software'), to deal in the Software without restriction, including
99 without limitation the rights to use, copy, modify, merge, publish,
100 distribute, sublicense, and/or sell copies of the Software, and to
101 permit persons to whom the Software is furnished to do so, subject to
102 the following conditions:
103
104 The above copyright notice and this permission notice shall be
105 included in all copies or substantial portions of the Software.
106
107 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
108 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
109 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
110 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
111 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
112 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
113 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.