Controlling the Fantastic Robot with Snap!

Controlling the Fantastic Robot with Snap!

by Citilab Edutec

Boards
Boards:

Citilab ED1

Component/s
Components:

None
This activity is part of the Citilab Course. Check it out!

Controlling the Robot with Snap!

Communication from a web environment: Snap!

  • As we have already seen in the previous unit, it is possible to communicate with the ED1 board through web requests (REST) ​​thanks to the fact that we can start a web server on it.

  • The web browser is not the only one that can make this type of request, they can also be made from other applications.

  • In this unit we will see how to control the robot from Snap!.

Sending commands from Snap!

  • Snap! is a block programming environment very similar to Scratch but which allows you to create more complex projects, thanks to the fact that it includes more advanced instructions than this one.

  • One of these instructions, the url _ block,allows web requests to be made in the same way as if they were made through the browser bar.

URL block

NOTE: for some reason it does not work in the Chrome browser and its derivatives, so it is recommended to use Firefox**.

Challenge 1: Control the robot with url blocks.

Challenge

Solution to challenge 1

Solution challenge 1

Challenge 2: Control the robot with the arrow keys on your keyboard.

Challenge

Solution to challenge 1

Solution challenge 2

  • It is also possible to control the robot with another MicroBlocks compatible board that supports WiFi, using the http:// _ block from the Client HTTP library in the Network folder.

Block HTTP

  • We will learn simpler ways to connect with Snap! later.
CC-BY-SA

© by Citilab Edutec 2019-2022.
This work is licensed under a CC-BY-SA 4.0 license.