forked from firmata/firmata.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-analog-read.js
48 lines (38 loc) · 1.08 KB
/
test-analog-read.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var Board = require("../");
Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}
var board = new Board(port.comName);
console.log(__filename);
console.log("------------------------------");
board.on("open", function() {
console.log(" ✔ open");
});
board.on("reportversion", function() {
console.log(" ✔ reportversion");
});
board.on("queryfirmware", function() {
console.log(" ✔ queryfirmware");
});
board.on("capability-query", function() {
console.log(" ✔ capability-query");
});
board.on("ready", function() {
console.log(" ✔ ready");
clearTimeout(timeout);
this.pinMode(0, 2);
this.analogRead(0, function() {
console.log(" ✔ received data (exiting)");
console.log("------------------------------");
process.exit();
});
});
var timeout = setTimeout(function() {
console.log(board.currentBuffer);
console.log(">>>>>>>>>>>>>>TIMEOUT<<<<<<<<<<<<<<");
console.log("------------------------------");
process.exit();
}, 10000);
});