Move the flag from the button

Let's use the button that was also used in UI Button Linkage in the block program lesson.

Try to raise the flag once the button is pressed.

Button display with the "if"

As a program, first add a UI button.The button will now appear on the screen.

You have to find out if it was pressed next.You need to find out if it is pressed in a loop.
And if it is pressed, raise the flag.

Program

The end result is a program like this.

First, add a button.Add "Make button with text" from "UI".
Change the text part to "give".
Then, enable iothomekit by "Connecting iothomekit to obniz".

Lower the flag before entering the loop.Lower the flag with "Lower the flag of iot home kit".

From here, prepare "Run all the time" so that it loops, and check repeatedly by putting "If" inside.
Put "button was clicked" in "UI" in the condition of if.
And if it is clicked even once, raise the flag with "Raise the flag of iot home kit".

When you run it and connect to obniz, a button will appear like this.The button design is slightly different depending on the model.

Let's press the button.The flag that is going down will go up by pressing it.

Your program runs a robot over the internet!
Even if you take your smartphone far away,Even if you go to a different country,You can run it remotely as long as you have the internet.

関連の質問