Grove:レコーダー v3.0
Groveのレコーダーv3.0を接続し、Tibbo-Piから録音と再生の制御を行います。
(Groveデバイスの詳細は上記リンクから参照願います。)
Tibbitの配置
Tibbit #00-3 と Groveデバイスを接続したTPbit #02を挿入します。
この状態で電源を入れれば、Groveボード上のボタン操作で録音・再生は行えます(操作方法は上記Groveデバイスのサイト参照)。
ノードで録音・再生を操作する場合は以下の設定を行います。
ノードの配置
chを指定するために、changeノードを使用します。
まず、録音の手順を作成します。以下のようにフローを配置します。
changeノードのプロパティを開き、以下のように設定します。
injectノードは名前のみ、「録音開始」、「録音終了」とそれぞれ入れてください。
Tibbit#00ノードの設定を開き、以下のようにスロットとOUT(オーブンドレイン出力)を選択します。
サンプルフロー
1 |
[{"id":"4303fc4a.c10e84","type":"inject","z":"c2fa6897.58c3f8","name":"録音開始","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":140,"wires":[["a4a2210e.58827"]]},{"id":"a4a2210e.58827","type":"change","z":"c2fa6897.58c3f8","name":"開始設定","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"B","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":140,"wires":[["45b93fcb.cfcf4"]]},{"id":"45b93fcb.cfcf4","type":"Tibbit-#00","z":"c2fa6897.58c3f8","name":"","tpSlot":"S01","communication":"GPIO","pinA":"other","pinB":"OUT_OD","pinC":"other","pinD":"other","i2cBaudRateK":"100","spiSpeed":"500","spiMode":"1","spiEndian":"1","serialConf":"","connectedStatus":"start","host":"","x":600,"y":180,"wires":[[]]},{"id":"e9ba3085.4bb97","type":"inject","z":"c2fa6897.58c3f8","name":"録音終了","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":220,"wires":[["5050d699.11e758"]]},{"id":"5050d699.11e758","type":"change","z":"c2fa6897.58c3f8","name":"終了設定","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"B","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":220,"wires":[["45b93fcb.cfcf4"]]}] |
次に、再生の手順を作成します。以下のようにフローを配置します。
changeノードのプロパティを開き、以下のように設定します。
injectノードは名前のみ、「再生」と入れてください。delayノードは時間を「0.1」とキー入力してください(プルダウンでは整数値しか選択できません)。
Tibbit#00ノードの設定を開き、以下のようにスロットとOUT(オーブンドレイン出力)を選択します。
サンプルフロー
1 |
[{"id":"6fc85ce1.3050b4","type":"inject","z":"c2fa6897.58c3f8","name":"再生","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["958c49ba.f5fed8","374aafd.703375"]]},{"id":"958c49ba.f5fed8","type":"change","z":"c2fa6897.58c3f8","name":"再生設定(ボタン押す)","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"A","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":300,"wires":[["1b324a2a.1bff36"]]},{"id":"1b324a2a.1bff36","type":"Tibbit-#00","z":"c2fa6897.58c3f8","name":"","tpSlot":"S01","communication":"GPIO","pinA":"OUT_OD","pinB":"other","pinC":"other","pinD":"other","i2cBaudRateK":"100","spiSpeed":"500","spiMode":"1","spiEndian":"1","serialConf":"","connectedStatus":"start","host":"","x":740,"y":300,"wires":[[]]},{"id":"374aafd.703375","type":"delay","z":"c2fa6897.58c3f8","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":410,"y":380,"wires":[["22c5c181.21d53e"]]},{"id":"22c5c181.21d53e","type":"change","z":"c2fa6897.58c3f8","name":"再生設定(ボタン離す)","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"A","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":380,"wires":[["1b324a2a.1bff36"]]}] |
Node-REDデプロイ後、injectノード「録音開始」を押すと、以下の写真のようにGroveボード上のLEDが点灯し、録音状態になります。
その後、injectノード「録音終了」を押すとGroveボード上のLEDが消灯し、録音が終了します(最大83秒)。
injectノード「再生」を押すと再生が開始されます。再生開始時にGroveボード上のLEDが一瞬点滅しすぐ消灯し、再生終了時に再度短く点滅します。
全サンプルフロー
1 |
[{"id":"6fc85ce1.3050b4","type":"inject","z":"c2fa6897.58c3f8","name":"再生","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["958c49ba.f5fed8","374aafd.703375"]]},{"id":"958c49ba.f5fed8","type":"change","z":"c2fa6897.58c3f8","name":"再生設定(ボタン押す)","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"A","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":300,"wires":[["1b324a2a.1bff36"]]},{"id":"1b324a2a.1bff36","type":"Tibbit-#00","z":"c2fa6897.58c3f8","name":"","tpSlot":"S01","communication":"GPIO","pinA":"OUT_OD","pinB":"other","pinC":"other","pinD":"other","i2cBaudRateK":"100","spiSpeed":"500","spiMode":"1","spiEndian":"1","serialConf":"","connectedStatus":"start","host":"","x":740,"y":300,"wires":[[]]},{"id":"374aafd.703375","type":"delay","z":"c2fa6897.58c3f8","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":410,"y":380,"wires":[["22c5c181.21d53e"]]},{"id":"22c5c181.21d53e","type":"change","z":"c2fa6897.58c3f8","name":"再生設定(ボタン離す)","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"A","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":380,"wires":[["1b324a2a.1bff36"]]},{"id":"4303fc4a.c10e84","type":"inject","z":"c2fa6897.58c3f8","name":"録音開始","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":140,"wires":[["a4a2210e.58827"]]},{"id":"a4a2210e.58827","type":"change","z":"c2fa6897.58c3f8","name":"開始設定","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"B","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":140,"wires":[["45b93fcb.cfcf4"]]},{"id":"45b93fcb.cfcf4","type":"Tibbit-#00","z":"c2fa6897.58c3f8","name":"","tpSlot":"S01","communication":"GPIO","pinA":"other","pinB":"OUT_OD","pinC":"other","pinD":"other","i2cBaudRateK":"100","spiSpeed":"500","spiMode":"1","spiEndian":"1","serialConf":"","connectedStatus":"start","host":"","x":600,"y":180,"wires":[[]]},{"id":"e9ba3085.4bb97","type":"inject","z":"c2fa6897.58c3f8","name":"録音終了","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":220,"wires":[["5050d699.11e758"]]},{"id":"5050d699.11e758","type":"change","z":"c2fa6897.58c3f8","name":"終了設定","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0].line","pt":"msg","to":"B","tot":"str"},{"t":"set","p":"payload[0].v","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":220,"wires":[["45b93fcb.cfcf4"]]}] |