必要なもの
Windowsで動かす場合にはBluetooth4.0に対応したアダプタが必要になる。私はAmazonでBluetooth USBアダプタを購入した。
事前にインストールするもの
1. python
https://www.python.org/ からpythonをインストールする。このときにAdd Python 3.x to PATHを必ずインストールする。
2. Zading
Zadingを使って汎用USBドライバーをインストールする。https://zadig.akeo.ie/ からインストールする。
手順
1. Zading Toolで汎用USBドライバーの適用をする
インストールしたzading-2.5.exe
を起動する。
options
からList All Devices
を選択する。Reinstall Driver
をクリックする。
successfully
と出たら完了。
2. toio.jsを動かす
2-1. toio.jsの公式サンプルをクローンする
(gitが入っていない場合はzipでダウンロードする)
ターミナル
git clone https://github.com/toio/toio.js.git
2-2. node-bluetooth-hci-socketをダウンロードする
toio.jsの中でnode-bluetooth-hci-socketをダウンロードする。
ターミナル
cd toio.js
git clone https://github.com/noble/node-bluetooth-hci-socket.git
npm install bluetooth-hci-socket
2-3. 実行する
toioCubeの電源を入れて、パソコンのBluetoothをオンにしてサンプルを実行する。
ターミナル
yarn install
yarn build
yarn example:id-reader // マットのidを取得する
yarn example:keyboard-control // キーボードでcubeを操作する
yarn example:chase // 1つのcubeをもう1つのcubeが追いかける