Page 144 - KEC Khaitan C6 Flipbook
P. 144
∑ On the left panel, click on the Extensions button (it looks like a square with a plus sign).
∑ In the search bar, type:
o Sonar (for ultrasonic sensors)
o Servo (for controlling servo motors)
o Click on the extensions to add them to your project.
Step 2 Using the Sonar Extension
The Sonar extension allows you to work with ultrasonic sensors like the HC-SR04 to
measure distance. Here’s how to use it:
∑ Once added, go to the Advanced category in the blocks editor.
∑ You’ll see a new block called sonar distance (cm), which can be used to get the
distance measured by the ultrasonic sensor.
Step 3 Using the Servo Extension
The Servo extension helps control servo motors using the Micro:bit. You can set the
position of the servo to a specific angle (0-180°).
∑ After adding the Servo extension, go to the Basic category in the blocks editor.
∑ You’ll see a block called set servo (Pin) to (angle), which allows you to control the
position of a servo motor.
CONNECTING TO THINKSPEAK WITH WIFI SHIELD
In today’s world, many devices are connected to the Internet, and this is what we call the Internet
of Things (IoT). Imagine if your Micro:bit could send the data it collects, like the temperature or
distance, to the cloud, where it can be stored and viewed from anywhere. This is where ThingSpeak
comes in. ThingSpeak is a website that allows you to store and view data from your devices, like
your Micro:bit, on the Internet. To make this connection, we need a WiFi shield, like the ESP8266
or ESP32, which allows the Micro:bit to connect to the internet. When you connect the Micro:bit
to ThingSpeak, it can send data to a cloud-based system, making it easy to track and view your
sensor readings from anywhere. In this section, we will show you how to connect your Micro:bit to
ThingSpeak using a WiFi shield.
WHAT IS AN API?
An API (Application Programming Interface) is a set of rules and protocols that allow different
software applications to communicate with each other. It defines how requests are made and
how data is exchanged between systems, enabling them to work together efficiently.
Let’s understand this with an example imagine you are at a restaurant. You look at the menu and
tell the waiter what you want. The waiter takes your order to the kitchen and brings back your
food. In the world of computers, an API (Application Programming Interface) works just like that
waiter!
142 Premium Edition-VI

