[No.14]水分警告パネルで水やりはバッチリ!
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/7uFlXIRfVNi2IxIGC6NOJ.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=%2Bp%2Bigl4JvX0pMEiSCoS6CIMDZLQ%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
みなさんは植物を育てるのは好きですか? 私はサボテンを枯らせてしまったことがあり、植物の栽培はどうも苦手のようです。水やりは時々でいいはずだから……と思ってついそのままにしてしまうのが原因。『そろそろ水をちょうだい!』と植物が教えてくれたら、さすがに申し訳ない気持ちになって忘れないはず……。どうにかできないかな……。 こんなときこそSPACEBLOCKで発明! 水が足りなくなったら顔マークで教えてくれる水やり忘れ防止装置を作ってしまいましょう。「土壌水分センサモジュール」を使いますよ。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/QQrBirYXtA6DP9Ng58nDa.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=CoWXI7t4as07dMDUowkIIIxnN8Y%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
必要なもの&準備
- SPACEBLOCK通常パッケージ[SPACEBLOCK本体、USBケーブル、電池ボックス]
- 土壌水分センサモジュール(土壌水分センサ)
- 8×8 RGB LEDマトリックスパネル(LEDパネル)
- ジャンパーワイヤ[ピンヘッダ-ピンソケット3本]
- プログラミングをするパソコン
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/0nnHs1fqZgHev4OJZTldm.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=L7taSYMd9cAdq7mU6dT2QJ4afww%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
SPACEBLOCKに拡張パーツを接続する
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/nVaddQmLhBDUB0MK1AjuR.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=JeBycOosm5shSjt1TC%2B%2Blv5p97M%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
細かい部分は次の図を参考にしてください。土壌水分センサの「G」「V」「S」から出ている3本のジャンパーワイヤをどこに挿すのかを確認してください。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/U2A-C8NEHKyjAYzy8rotA.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=eL8%2FdToisIWYLL4nZNEbYbLRjAE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
土壌水分センサって?
土壌水分センサは、土の中の水分量を測定することができます。水分がない状態が0で、水分が多くなるほど数値は大きくなります。このように量や大きさなどの程度を数値でプログラムに渡すことをアナログ入力と呼びます。
土壌水分センサは、測定した水分の量に応じてSPACEBLOCKに挿したピンヘッダの電圧を上げたり下げたりします。電圧の程度に応じて0から1023までの数値に置き換えてプログラムに値を渡しています。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/w1IVTk-ZzxH8GxPlwtNOm.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=7HXyAFMCCKO0OlL%2Ba4Z6l7OYWfY%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
土壌水分センサの値をチェックしてみよう
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/A3wels-xLnjB3zX1XKxUK.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=oLSkNA5dv3mNSiquhDkI3E5tLp8%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
プログラムを実行すると、土壌水分センサが測定した値がコンソールに表示されます。銀色のセンサ部分が何にも触れていないと値は「0」ですが、指ではさむだけでも水分を検知して数値が上がります。水に濡らしたティッシュではさんでみるなど数値の変化を確かめてみましょう。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/M0kIAsZxLPZ3j70Q4o9WO.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=BKvzF88DL2VAZ%2FsdG1V4UQaDAiI%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
土壌水分センサの銀色の部分以外には、水がつかないように注意してください。SPACEBLOCK本体や配線部分も水がかからないように扱ってください。故障や発火などの原因となります。水がかかるおそれのある部分には絶縁テープを巻いて安全に使いましょう。ビニールテープも利用できますが、防水性にも優れたブチルゴムという素材のテープは接着剤ではなく素材同士がくっつき合うので扱いやすく便利です。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/tlbLVyqxUXAlmWTG-a0WD.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=pCjbDzIOpsnxDcGlirwmQ9pHShE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
土の乾き方によってLEDパネルの表示を変えよう!
土壌水分センサの使い方がわかったところで、早速LEDパネルで警告を出す仕組みを作りましょう。
変数を作成する
新しい変数を作成し「water」と名前をつけます。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/yUWaEiD6E-Qnfcf47sbkF.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=sxhJx%2Fiix0tGtB50WDxAFOiho2w%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/wyNFXY8AwK-dQf_-6THVe.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=06RjBnjLE6gFt3mzU3%2BDeTAnd2g%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
条件で処理を分ける
続けて、LEDの表示を切り替えるプログラムを作成します。土が少し乾き始めた状態で軽い警告を出し、かなり乾いた状態で強い警告を出すことにします。どのくらいの値で警告が出るようにするかは、実際に植木鉢に土壌水分センサを挿して、土の状態でどの程度数値が変わるかをチェックして決めましょう。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/NOaaEPMU4jj2OYjNcXwbq.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=CDZAHbhKhFPnUKR9TMoIUhS6I7c%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
値の参考値は、以下の通りです。
[参考値]
- 0~300 乾燥している土
- 300~700 湿った土
- 700~950 水中
今回は土壌水分センサの値が500より小さくなったら第一警告を出し、300より小さくなったら第二警告がでるようにします。次の図の通り、[もし《 》なら…でなければ…]ブロックと[《0》《=》《0》]ブロックで、値によってLEDパネルの表示方法を3通りにわけてください。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/vfP3c-yh_jW0yZ68vUoIr.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=eeXFleb5oNXckrFQZ8m28r6PX2k%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
LEDパネルの表示を指定する
[もし《 》なら…でなければ…]ブロックの間にLEDパネルの指定を追加すると、次の図の通りプログラムが完成します。LEDパネルに顔を表示して感情に訴える作戦です。
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/EHmxzzRRSQ_WCFmddOBFi.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=G084YhdcYKZHZzZwmh2G8sIxho0%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
プログラム完成
これで完成です。土の乾き方に応じて警告が出るようになりました!
土が十分湿っているときは何の反応もありませんが……
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/ro-csq5PYojQi4_8r-xyK.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=3c0Ix6sRQr99dBMs7Wv2Im%2Bu3sw%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/AlK6nD3kBbJYjE9A4dW8f.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=5Hjc4qO7LqYUMLYcTq%2B6%2F5ys0mo%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
赤い 『もうダメ!!』な顔が出ています。もう限界みたい! はやく水を!!!
![](https://s3.ap-northeast-1.amazonaws.com/spaceblock.jp-storage/inquiries/2024-03-26/auOhk5Ib9jfDGOSeTQKvy.png?AWSAccessKeyId=ASIAZZVIWFLRWQMXT63U&Expires=1725769838&Signature=iYrVkA0xAoQvqQ8hoyg1y6JqF3I%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEBIaDmFwLW5vcnRoZWFzdC0xIkcwRQIgfM5u%2B8u2RgeBUerDvFxtux%2F2xbFkN60i2sB7SLNEmmQCIQDu%2BeJQLvvOVeTJPpg4%2BCeNUuodg5xO9h8dHr81XlE7QCqUAwg8EAEaDDY3MzU4OTg5Nzk1NSIM6DLui2OwS0ort6yNKvECJ3W6zoqqFaUrW9v8rTtYRGPzlVtF7b4hXyI4EKJ%2FXbk2k1GfdLpmFY%2FLIwWwsaCFLsfJlzfs84XBY1NWLeW8abfUekA%2F9dkAxZLyGQTNzhaQ1YdNsbL0V7LlMy%2FkHvyDQMTsCjC2v2EcvLvC8JVF7krG2ME4WMHpv5HpOsdKX8ZSojrMbPTEKSLVskSrKijglgGvssv0N8re1Qdx0djM4awCWpDIxfzcO0rqEbvQJHfPwdKKyhIIPZolIdWhnaxEnqUg52%2BaqRFs6cUMUSREhjzFcpu7NuoWuTRh6mSypK2emcrHZR07XP%2F0NVv8IL8zOsrHNyRokmdDQXHeZReT%2Bn%2FlMbLIGIg59sWIC7%2B2752noShjJHHWv%2FQLKvxCg7xqrBoliJ6i2l8R83JzaJrrBkY3MhA5ptqxUcsAAtumUSRPgopjdrAAwsN0yviL9aIYZLbGxqOXHNlfNx%2Bo5HcOEzVuE%2F5yOZ%2BvJJODecPLIFObMPaU9LYGOp0B2eLKz8GlBqxdNowsI%2BmhoU7y45XhYmV8u52oOMfJnmQfM6QgdgTNsq20izYPkX2mM1jjSW0pA66qB1TKbKGLYL4cQbhnQ03NN%2BL3ZAhIfMfFOHJee%2BxZYJOkS27rwyJoi06r4W97VmdTMKHPLu6bvvzqu%2F8ikiLIAuaFqdmyO6%2BK6CnUIaHnhgcR79Bd2M69ktHQHqcKsHTvZqzNLw%3D%3D)
これでもう水やりは忘れないはず!!