我尝试使用node.js从传感器连续读取数据。假设我的传感器连接到Arduino的数字引脚4,在代码的节点端如何编程?
我试过这个: Node.js代码:
$("li").html( $("span.title").text().trim() );
这是我得到的错误:
(node) warning: possible EventEmitter memory leak detected. 11 digital-read-4 listeners added. Use emitter.setMaxListeners() to increase limit. Trace at addListener (events.js:239:17) at Board.digitalRead (C:\Users\Rahul\Desktop\NodeServoTest\node_modules\johnny-five\node_modules\firmata\lib\firmata.js:827:8) at Board.(anonymous function) [as digitalRead] (C:\Users\Rahul\Desktop\NodeServoTest\node_modules\johnny-five\lib\board.js:495:21) at Board. (C:\Users\Rahul\Desktop\NodeServoTest\digitalRead.js:12:8) at wrapper [as _onTimeout] (timers.js:275:19) at Timer.listOnTimeout (timers.js:92:15)
答案 0 :(得分:1)
你应该使用这样的东西:
var five = require('johnny-five');
var board = five.Board();
board.on('ready', () => {
var pin = new five.Pin('A8');
pin.on('data', data => {
console.log(data);
})
});
在这种情况下,我正在读取模拟引脚8上的所有数据。