[No.13]光るビーチボールを作ろう!
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/LLHBnCl8vVPcM_schKQzg.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=fn5v6HUA7gNl4%2Bb%2BXXc6fH%2FK3YU%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
前回の記事で「三軸ジャイロ三軸加速度センサモジュール」の角度の値を使いましたが、今回は加速度の値を使って不思議な光るビーチボールを作ります。拡張パーツの楽しい仲間「スペースボール」を使いますよ! スペースボールはSPACEBLOCKを包み込める特別なビーチボールです。
必要なもの&準備
- SPACEBLOCK通常パッケージ[SPACEBLOCK本体、USBケーブル、電池ボックス]
- 三軸ジャイロ三軸加速度センサモジュール(三軸ジャイロセンサ)
- 8×8 RGB LEDマトリックスパネル(LEDパネル)
- スペースボール
- ジャンパーワイヤ[ピンヘッダ-ピンソケット3本]
- プログラミングをするパソコン
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/2y9mqRmur6CJQZStLYctI.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=HaYAx5aIcLYfeW9TUJlEp2SZu%2FE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
SPACEBLOCKに拡張パーツを接続する
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/v4iqRv4fCUnZnm6unkISs.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=04msgzL72hDTIl7sQ2rrBHtpsY4%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
三軸ジャイロセンサの加速度って?
加速度の3つの軸
加速度は動きのスピードです。三軸ジャイロにはX軸、Y軸、Z軸があり、それぞれの軸に対してどんな向きで動いたかを加速度X、加速度Y、加速度Zで測定できます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/XMkiB4Kjxhmtu3Uw12uUl.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=f1gGjTXQAwq9MBoB19Idp6nme74%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
加速度の値の範囲
動くスピードが遅いと0に近く、速いと100に近い数字になり、軸ごとにプラスの方向とマイナスの方向の傾きがあります。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/wr7oJ0Mr8QB4yo2XsuDBL.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=AK1nOK1vH8hAzeLMVwwrtPiz4Mg%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/SLwMcYBFu-klh8VawGJHn.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=UyoDOaeVniSEKUV39iqMPbF%2Bwlk%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
加速度の値をチェックしてみよう
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/v4SwHvgfFedu66IBROOdt.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=y3qDfuzmJEp%2F91lwp2c0rOOg%2FVA%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
実際に、加速度の値をコンソールで確認してみましょう。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/lCZn4nLNZa3HFC5ghksyk.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=wDpjvcJBHFuMw0j4GGzNQd8qIUs%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
プログラムを実行し、三軸ジャイロセンサをつけたSPACEBLOCKを動かしてみると、傾きの方向やスピードに応じて値が変化するのがわかります。「X」、「Y」、「Z」、「絶対値」の値と動きの関係をそれぞれ確認してみましょう。なお、「絶対値」には、X、Y、Zの加速度の絶対値のうち最も高い値が採用されます。
加速度に応じてLEDパネルの表示を変えよう!
それではいよいよ光るボールの制作です。スペースボールをふくらませるのは最後のお楽しみ。まずはSPACEBLOCKのプログラムをします。ボールはいろいろな方向に動き続けますから、向きは関係なく動くスピードによって光り方が変わる仕組みにします。加速度の「絶対値」を使ってプログラムを作成しましょう。
変数を作成する
新しい変数を作成し「acceleration」と名前をつけます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/B_dan1UfOQ60P3JPSUtVZ.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=mXgDkb%2FjomZB6CfHh4%2Bgj1pa1RE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
[繰り返す]ブロックと[数字《変数名》に《 》をセット]を組み合わせ、変数「acceleration」にジャイロの加速度「絶対値」を入れるように指定します。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/uqq8l2PM4O-ZE1XRiibRp.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=68fpvdvC9jJE%2FXJK4Bj6OBIV6wo%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
条件で処理を分ける
続けて、LEDの表示を切り替えるプログラムを作成します。[もし《 》なら…でなければ…]ブロックと[《0》《=》《0》]ブロックで、加速度の値によってLEDパネルの表示方法を4通りにわけます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/SycNbM-KiYUsPFDAKKa8r.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=VDsgNBhLreq6v5aAsGETkx0tRPw%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
LEDパネルの表示を指定する
[もし《 》なら…でなければ…]ブロックの間にLEDパネルの指定ブロックをいれると次の図の通りプログラムが完成します。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/7mbNSBnInlTkHWCKh6Kun.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=lxiqffkzvgSf9srDKZo3nqrAur0%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
プログラム完成
プログラム部分はこれで完成です。動かすスピードの速さでこのようにLEDの表示が変化します。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/zzmR1AZvGtiaWnWIs3WPt.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=ioqeoMC0seD5TdCpCxwThHrURdk%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
プログラムを実行したところを動画で見てみましょう。
スペースボールにセット!
それではいよいよスペースボールを使いますよ! スペースボールに空気をいれてある程度ふくらんできたら真ん中の筒状の空間にSPACEBLOCKを入れてさらにしっかりふくらませます。
スペースボールに入れる前に、SPACEBLOCKと電池ボックス、LEDパネルを重ねてテープでとめるなどしてまとめておきましょう。とがった箇所がボールに穴をあけてしまわないように、緩衝材で包んでおくと安心です。先に電池ボックスのスイッチをONにしておくのを忘れないでくださいね。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/v5Ezxtkn4BM-bMLlQKjKC.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=IrTipljXR7%2BTcjgoNEUwDh2n4Dg%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
SPACEBLOCKは空気の力で固定されます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/5FaQ_sTxnfdGSA_hkc8Ow.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=i2wIabtEjDZe1aChKoTfi%2BCq7OQ%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/sSkCkZABWs1GrMk6_d9gp.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=RUUO9ZM2MyQoni2cwWkkqXdzo4A%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/2Oc4YBgw8gaY176XF3lj-.png?AWSAccessKeyId=ASIAZZVIWFLRYPYCASPF&Expires=1725770657&Signature=udsvrfDAA%2BW0iqkUEAWoHabVozM%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkgwRgIhAMKKk4aPUJn0e3SMDa3%2FAteardhsO4C2QmZ%2FkpDJXcREAiEA5h1%2BhXMSAVKKhjvcAZ3JU%2FoECFek1D9LtUesx0G6ZkcqlAMIOxABGgw2NzM1ODk4OTc5NTUiDLP6gTNK2iBRQ0QEgCrxAre5ARThtFYiP5HewoKJlDsZ%2Fym9MJOratwTQ9mb3bhJubMItXViaFiSPI8BowsTLnGCxorQFqzSDW9PG05Z4D1jSUBH9Mhn0XE3SM%2BH66V86Tnci%2BdakfPPKnmEzbccndH80Z6m4jfOFQKHWXUuWNb0lBa6WFR9MmesdFj88%2FRRBgooF8chJBXQ9uBZgq%2FAuaY%2Bbyly3iIlMWXpgXUQy1tLuD5Sq7HEF8%2FB5ziU40hTprO%2B2jFPcRPNIhJEFNy%2BJpj%2Fq9ftmp2wYSuTwDF30wnZdZsiVW1pxwjadXMPUEecpeKukqEhtKcyl1IOIlojPFJphRJZZ%2BY0vgBgKhD%2BJZiKG3Kx9FSKT9Dz1sYdfWMQElc6yFFOnZ6R5hpdSHVWxLLdEW8d8S85H5xlSb26Q0JiCNupA4u9jENLdP%2BS02ry0q19vEzYrD%2B%2Fmo6gjXXZa6U66dUlVLSmhl0ZV%2FD17G4DrbZyTZIPv8okvFZpqYvvUTCpivS2BjqcATPuLjpWxhuwUWl1HwkKq2WH3PK4sfLQGRY%2Fmc8xZ0IzU6IDaMosEV%2B4LFr33F1IadIBT9rZVJZ2BBeI6vAQnKMWSeEnjHIXZANw8%2Fk0Kw7DNj46HKVTWfWkDGwH5a3MvBjxo18yawLeYwNSfetGVpS6TMMz8BArcKp7OTbcaLeyXC4Qr%2F0Hoevcuipf9syVdc74eLpb6gIDf9r4Qg%3D%3D)
動画でみてみましょう。
この例のように光らせて楽しんでもいいですし、そぉっと運んで光ったら負け!というゲームに使うのもおすすめ。どのくらいの動きで光るかはプログラムを調整すればいくらでも変更できますから。いろいろな遊び方を考えてみてくださいね!
最後にSPACEBLOCKのオフィシャルページで紹介されている動画をご紹介します。
こんな光るボールを作るワークショップ、とても楽しそうですね!!