[No.11]音楽に連動するパーティーライト!!
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/PhSY_XlBWQopwZ2oG_SMC.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=woZEaJFHI%2BZASJpt%2Fy9zBNW%2FdIE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
家でパーティーをするとき、音楽を流すと雰囲気が出ますが、もっと盛り上げたいときには……ライトの演出なんていいかも? とはいえ、パーティーライトなんてたまにしか使いそうもないものを買うのはちょっと気が進みません。そんな時こそSPACEBLOCKで発明しちゃいましょう!
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/nPgvdNTU6rvk7lyiKvVu4.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=lRUULISCpXYDNnLnhIJCjgV7o8I%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
今回の発明には「マイクセンサモジュール」と「8×8 RGB LEDマトリックスパネル」を使います。音楽に合わせて自動的に演出が変わるパーティーライトを作りますよ!
必要なもの&準備
- SPACEBLOCK通常パッケージ[SPACEBLOCK本体、USBケーブル、電池ボックス]
- 8×8 RGB LEDマトリックスパネル(LEDパネル)
- ジャンパーワイヤ[ピンヘッダ-ピンソケット3本]
- マイクセンサモジュール(マイクセンサ)
- プログラミングをするパソコン
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/l7LeFWyqZxzh2rUhLgbpt.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=gYIXEMZK3SDD6m0XQsyYUgfQ06U%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
SPACEBLOCKに拡張パーツを接続する
まずは、今回使用するLEDパネルとマイクセンサをSPACEBLOCKに接続してみましょう。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/a7ZXffn_k7QuSVhJorHEA.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=n%2Bye5SYwD96kxZPS52dqqwgrXMo%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
細かい部分は次の図を参考にしてください。マイクセンサの「G」「V」「S」から出ている3本のジャンパーワイヤをどこに差すのかをよく確認してください。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/zss_Kgkf2JyKTLxmJAIF4.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=ldO7Z1PPbCskYlaLea1M3qO5eCg%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
マイクセンサって何ができるの?
マイクセンサは、音の大きさを測定することができます。音がしていない状態が0で、音が大きくなるほど数値は大きくなります。このように、音の大きさなどの程度を測定し数値にしてプログラムに渡すことをアナログ入力と呼びます。
マイクセンサは、測定した音の大きさに応じてSPACEBLOCKに挿したピンヘッダの電圧を上げたり下げたりします。電圧の程度に応じて0から1023までの数値に置き換えてプログラムに値を渡しています。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/YHPJJqgGN4VdmqkplgebX.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=NYsRKvQnbUu1I5YTsGRu1hpNDZw%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
マイクセンサの値をチェックしてみよう
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/hHFFUaDe91l1DIyZW031l.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=SpNfQZNPxtHgQZw8cRniEmneRgE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
作成したプログラムを実行すると、マイクセンサの値がコンソールに表示されます。静かにしているときと、音楽を流した時などでどのように値が変化するかを確認できます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/e8G4f6SsT0cGrN3v9zyTv.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=7SWQaCoZkbZFD4umQ6qwFAGNcog%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
動画で見てみましょう。音楽が流れると値が高くなることがわかりますね。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/pzG6DDpqQB72D233tzN-x.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=CrsgttlHAPowJ3uiGNi1stlmhBE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
音楽に合わせてLEDパネルの明るさを変える!
それでは、まずは音楽に合わせてLEDパネルの明るさを変えるプログラムを作りましょう。マイクセンサの値を、LEDパネルの明るさ指定に使って、音の大きさに応じて明るさが変わる仕組みです。
まず、マイクセンサの値をプログラムの中で使いやすくするために「変数(へんすう)」を作成します。「変数」は、値を入れておくことができる入れ物で、自分で好きな名前をつけられます。次の図を参考に、「数字」型の「sound」という名前の変数を作ってください。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/QIHn8re1tjpaAsAYJNPgV.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=IoQJj0vhC9v79j%2FA%2Fq8DzH%2B%2BGgM%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/05rcIeBRHEyW_CKp7zlzk.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=pXtNuNy%2BVQZacE4jG%2BKRHYuaV9c%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
このプログラムのマイクセンサの値のように、同じ値を2回以上使うときは、変数に入れて使いましょう。
これで、音の大きさに応じて明るさが変わる仕組みができました。
LEDパネルの明るさは0〜100%で指定できます。マイクセンサの値が0〜およそ100くらいの場合、マイクセンサの値をLEDパネルの明るさ指定に使うのがぴったりです。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/gTiNWQ7T2GQQuKfwUhR7l.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=qs%2Bj7%2FZpYccy%2BXtimhI4MvZyWPk%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
ただし、マイクセンサの値はマイクセンサの感度や音楽の流し方によって変わります。もし、マイクセンサの値の範囲が広く、100以上の値ばかり出る場合は、計算して一定の割合で小さくすると、明るさの指定にふさわしい数値にできます。
次の例は、変数「sound」にマイクセンサの値を入れる際に、0.5をかけるという計算をして値を半分にしています。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/shLVkFdIm3vCTC6aT-NPI.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=fKNfOZhouTC73RSQEVOLpgQ%2F4n8%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
さらに派手な演出にアレンジ!
明るさに加えて、ライトの点灯する箇所や色にも変化をつけましょう。マイクセンサの値を入れた変数「sound」の数値に応じて次の図の通りLEDパネルの表現を変えることにします。ボリュームゲージが上がっていくような演出ができます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/NOICJNH9VeJ5qU3gYAy85.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=%2Fxo6yhFbBkNeSRGHHak8k67yRBo%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
プログラムを作っていきましょう。まず、先ほどと同じプログラムです。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/04oyIDHwS09TtXbL2atY9.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=UIs0%2BM%2BYchfoNapPelHRpXQgsrU%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
次に、条件によって実行する命令を分けるプログラムを作ります。「論理」カテゴリーの[もし《 》なら…でなければ…]ブロックを使います。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/FXWIGSqt5FW7YJZef7MS-.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=dKi8Y0Y%2Bibwzr4iSh9%2B31eA4LlY%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
[もし《 》なら…でなければ…]ブロックを使って、5段階に命令を分けます。[もし《 》なら…でなければ…]ブロックの条件部分には「論理」カテゴリーの[《0》《=》《0》]を入れ、次の図の通り式と数値を指定します。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/neS9ymxK3ocYzxsLwWFb3.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=t8oUiDdPcyVHMQOfz%2BM%2FxBQHuxU%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/mPDtBI1OEeIrslenyjlyf.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=XedywW1kRdduzcIGFRhVS%2B7QA0A%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
これで完成です。
プログラムを実行してみましょう。
ライトらしくアレンジ
このままでは味気ないので、SPACEBLOCKをスタンドアローンモードにしてプログラムを転送し、半透明のボックスに入れて、ライトらしく見せます。
こんなふうに適当なボックスに入れるだけ!
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/frXJINaypGo9rntanSEqC.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=xyXSRZk5B9dIwU4LEmerkcDqaG0%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
ちょうど上にスマートフォンを置いて使えます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/k4fLOb1rcG9hZKV0brUyu.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=81YnRITeF1lwakYkIj50Kdvwx3s%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
動画で見てみましょう。
まず、少し明るいところで。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/ioSp81aq6L-547zPBL-7F.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=tkR1SgvbXNun1S3sVuFRYqIrRbo%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
マイクの音量に応じて、明るさと点灯箇所の両方が変わるため、ダイナミックな感じになります。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/ZHvCoUqTCABZJi7KQ_JK7.png?AWSAccessKeyId=ASIAZZVIWFLR7GFJEP3T&Expires=1725758901&Signature=cJYW1d9LTB1gOTg8oA1vaKIc2%2FI%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEA8aDmFwLW5vcnRoZWFzdC0xIkgwRgIhAJcqDSvBAqICNf4%2Fxp2qUSlpqnIxDSt5zpLgO2mlR63fAiEAhtcl4r8oTHEsLeoy7OrxYK67ktcyjykoscz8p2xzBVYqlAMIORABGgw2NzM1ODk4OTc5NTUiDIeyG9x4tkr22A3OPirxApVrw0EtEqAGgTX9FVkHAorkxY5Au3R0qt5tCbldQIKY8ASCzp04uSP676anev9uu%2BLeT0FxWLJV3%2BMZR%2BtxUCfgJSXnKg4XNe4DGRnErB83VOmv%2B4cWF6htXDKFu3eDbTpKQL1DtHBFi6pqb0huuxKtarRcB%2B0cxIkeUa0OOxmDFNNwcijuMJRxrzlLxN3hEXjQ4v%2BA1Zto%2BUlCIztfLY23%2F4%2BOiArwuF81DBootTMxCOLi2sttDwG31kXvEuLfC7GmKkFnfApskn4UWar%2BKJO945Bdfgi5Zh5Q%2Fn77IvoBzN2auXEc8QKunl6xPbYh78Nzn20cywPRc5gV4Pr7uziQNRSyqgY2PCyK4ShlMwTlS3GdXVEydEdR3YVctJeExOronb7xI8%2BB%2BG4ld11QteRyRWLRil5ge8siK5cwBRGDaj3rRMJ8%2BUBvr3ovpWBXBJwuLL0k3qx10pkIn7%2BqVHUhoKfkuA%2Bk%2BS4MDkYxV1g1UzC0wfO2BjqcAWdfkra8nDL316zItJHOCIzM7qm2LKDR6Ti9WN9ApttaB46cRbbStDZkNZ3EJhwJn53e%2BZXnVYeugC3%2BOh5OesKTEujCDdfRQ0r8ovy7vMyg357tQ%2FFPqx7iMgQnrVHQcZlJeyb3AZw3HJt58oAA7fOZzckhkdD3T3bI6vgF48pauAXjbjszIyXJWoWSRjnt1MebeMNwDek6R0ggkg%3D%3D)
どんな曲が合うかいろいろ試してみましょう。色や光らせ方を変えるとまた違った雰囲気に。流したい曲やパーティーの気分に合わせて自由にアレンジしてみてくださいね!!
パーティーライトがあったらな……と思ったら、こんな専用ライトを発明できてしまいました。みなさんも「欲しい」を実現するものづくりにどんどん挑戦してみましょう!!