You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+87-1Lines changed: 87 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,16 @@ The way this works is simple (in theory, not in practice). The Arduino listens f
36
36
37
37
##board
38
38
39
-
Right now, the board library will attempt to autodiscover the Arduino. I'm going to make it configurable, don't worry.
39
+
````javascript
40
+
var board =newarduino.Board({
41
+
device:"ACM"
42
+
});
43
+
````
44
+
The board library will attempt to autodiscover the Arduino.
45
+
The `device` option can be used to set a regex filter that will help the library when scanning for matching devices.
46
+
**Note**: the value of this parameter will be used as argument of the grep command
47
+
48
+
If this parameter is not provided the board library will attempt to autodiscover the Arduino by quering every device containing 'usb' in its name.
40
49
41
50
````javascript
42
51
var board =newarduino.Board({
@@ -119,6 +128,67 @@ Fade the to full brightness then back to minimal brightness in `interval` ms. De
119
128
120
129
Current brightness of the LED
121
130
131
+
##lcd
132
+
133
+
This is a port of the [LiquidCrystal library](http://arduino.cc/en/Reference/LiquidCrystal) into JavaScript. Note that communicating with the LCD requires use of the synchronous `board.delay()` busy loop which will block other node.js events from being processed for several milliseconds at a time. (This could be converted to pause a board-level buffered message queue instead.)
134
+
135
+
````javascript
136
+
var lcd =newd.LCD({
137
+
board: board,
138
+
pins: {rs:12, rw:11, e:10, data:[5, 4, 3, 2]}
139
+
});
140
+
lcd.begin(16, 2);
141
+
lcd.print("Hello Internet.");
142
+
````
143
+
144
+
In `options`, the "pins" field can either be an array matching a call to any of the [LiquidCrystal constructors](http://arduino.cc/en/Reference/LiquidCrystalConstructor) or an object with "rs", "rw" (optional), "e" and a 4- or 8-long array of "data" pins. Pins will default to `[12, 11, 5, 4, 3, 2]` if not provided.
These are similar to the methods in the [LiquidCrystal library](http://arduino.cc/en/Reference/LiquidCrystal), however they can take an optional boolean parameter. If true or not provided, the setting is enabled. If false, the setting is disabled. For compatibility `.noDisplay()`, `.noCursor()`, `.noBlink()` and `.noAutoscroll()` methods are provided as well.
153
+
154
+
###lcd.write(val), lcd.print(val)
155
+
156
+
These take a buffer, string or integer and send it to the display. The`.write` and `print` methods are equivalent, aliases to the same function.
157
+
158
+
###lcd.createChar(location, charmap)
159
+
160
+
Configures a custom character for code `location` (numbers 0–7). `charmap` can be a 40-byte buffer as in [the C++ method](http://arduino.cc/en/Reference/LiquidCrystalCreateChar), or an array of 5-bit binary strings, or a 40-character string with pixels denoted by any non-space (`' '`) character. These bits determine the 5x8 pixel pattern of the custom character.
161
+
162
+
````javascript
163
+
var square = new Buffer("1f1f1f1f1f1f1f1f", 'hex');
164
+
165
+
var smiley = [
166
+
'00000',
167
+
'10001',
168
+
'00000',
169
+
'00000',
170
+
'10001',
171
+
'01110',
172
+
'00000'
173
+
];
174
+
175
+
var random =
176
+
". .." +
177
+
" . . " +
178
+
". . ." +
179
+
" . . " +
180
+
" .. " +
181
+
". . " +
182
+
" . ." +
183
+
".. .." ;
184
+
185
+
lcd.createChar(0, square);
186
+
lcd.createChar(1, smiley);
187
+
lcd.createChar(2, random);
188
+
lcd.setCursor(5,2);
189
+
lcd.print(new Buffer("\0\1\2\1\0")); // NOTE: when `.print`ing a string, 'ascii' turns \0 into a space
190
+
````
191
+
122
192
##piezo
123
193
124
194
````javascript
@@ -164,6 +234,20 @@ setInterval(function(){
164
234
}, 1000);
165
235
````
166
236
237
+
##ping
238
+
239
+
See:<http://arduino.cc/en/Tutorial/Ping>
240
+
241
+
````javascript
242
+
var range =newarduino.Ping({
243
+
board: board
244
+
});
245
+
246
+
range.on('read', function () {
247
+
console.log("Distance to target (cm)", range.centimeters);
248
+
});
249
+
````
250
+
167
251
##servo
168
252
169
253
````javascript
@@ -213,6 +297,8 @@ What is implemented right now:
0 commit comments