言語切り替え

Use distance sensors to check if apples are missing [IoT Home Kit]

Make things

You can make sure that your apples are not being taken by others.

Materials

※This article is an example of how to make it using the IoT Home Kit.

  • IoT Home Kit
  • Smart Phone or PC
  • power supply
  • apple (fruit)

How to make

Hardware Connection

Follow the guide to assemble the Iot Home Kit.

 

Software

Lines 3~5 define the image and text to be output to the browser.

After row 6, use the distance sensor to measure the distance of the apple.

Here, the important block is the repeat do block.

The distance sensor on the repeat do block constantly measures the distance to the apple.

In the block, if you define a block and the distance sensor’s measurement distance is more than 20cm (in this case, let’s put the apple within 20cm), the image created in line 3 will move by 5px, and the inside of the label created in line 5 will be rewritten as “taken”.

Once the apple is taken, the label is written as “There is more”, but the position of the animation of the moving apple does not change.


With just this much block programming, I was able to check if my apple had been taken or not while I was on the go.

You’ll be able to see if there’s a variety of things besides apples, so give it a try.

Program