2015年7月5日日曜日

arduino-firmata

橋本商会様

http://shokai.org/blog/archives/8559

に従い、arduino-firmata を Node.js command prompt からインストール
C:\Users\Mobile>npm install arduino-firmata
|
> serialport@1.7.4 install C:\Users\Mobile\node_modules\arduino-firmata\node_mod
ules\serialport
> node-pre-gyp install --fallback-to-build

[serialport] Success: "C:\Users\Mobile\node_modules\arduino-firmata\node_modules
\serialport\build\serialport\v1.7.4\Release\node-v14-win32-ia32\serialport.node"
 is installed via remote
arduino-firmata@0.3.2 node_modules\arduino-firmata
├── eventemitter2@0.4.14
├── debug@2.2.0 (ms@0.7.1)
└── serialport@1.7.4 (bindings@1.2.1, sf@0.1.7, async@0.9.0, nan@1.8.4, optim
ist@0.6.1)
インストールはうまくいったようだ。

使い方は以下を参考に
https://www.npmjs.com/package/arduino-firmata

ただ、エラーが出てうまくいかない。

var ArduinoFirmata = require('arduino-firmata');
var arduino = new ArduinoFirmata();

arduino.connect();  //use default arduino
arduino.connect('dev/tty/usb-device-name');

arduino.on('connect', function(){
  console.log("board version"+arduino.boardVersion);
});


■johnny-five 
その後、johnny-five でもうまくいかず。
http://ics-web.jp/lab/archives/4758
https://github.com/rwaldron/johnny-five/wiki/Board

以下のエラーが出る。
スクリプトは以下のもの。comポートを指定してconnectは出来たようだが、その後が進まない。
ここのトラブルシューティングを調べてみる。
https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooting



var j5 = require("johnny-five");
var arduino = new j5.Board({port:"COM11"});

console.log("ssugi");

arduino.on ("ready", function() {
  //
  var led = new j5.Led(2);
  this.repl.inject({
    led: led
  });
});
C:\Users\Mobile>node j5_ledblink150705.js
1436087045693 Connected COM11
ssugi
1436087055696 Device or Firmware Error A timeout occurred while connecting to th
e Board.

Please check that you've properly flashed the board with the correct firmware.
See: https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooti
ng
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: A timeout occurred while connecting to the Board.
    at Board.<anonymous> (C:\Users\Mobile\node_modules\johnny-five\lib\board.js:
411:26)
    at Timer.listOnTimeout (timers.js:119:15)

C:\Users\Mobile>

0 件のコメント:

コメントを投稿