○基本回路/プログラム
◇Arduino
・配線
◇Raspberry Pi
・配線
アダプタ
|
Raspberry Pi(※)
|
-
|
6
|
+
|
4
|
d
|
3
|
c
|
5
|
※物理的なピン番号で表記しています。
・プログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var raspi = require('raspi-io'); | |
var five = require("johnny-five"), | |
board, nunchuk; | |
board = new five.Board({ | |
io: new raspi() | |
}); | |
board.on("ready", function() { | |
// Create a new `nunchuk` hardware instance. | |
nunchuk = new five.Wii.Nunchuk({ | |
freq: 50 | |
}); | |
nunchuk.joystick.on("change", function(event) { | |
console.log( | |
"joystick " + event.axis, | |
event.target[event.axis], | |
event.axis, event.direction | |
); | |
}); | |
nunchuk.accelerometer.on("change", function(event) { | |
console.log( | |
"accelerometer " + event.axis, | |
event.target[event.axis], | |
event.axis, event.direction | |
); | |
}); | |
["down", "up", "hold"].forEach(function(type) { | |
nunchuk.on(type, function(event) { | |
console.log( | |
event.target.which + " is " + type, | |
{ | |
isUp: event.target.isUp, | |
isDown: event.target.isDown | |
} | |
); | |
}); | |
}); | |
}); |
※APIの詳細は、Arduinoのプログラムを参照してください。
0 件のコメント:
コメントを投稿