In this activity, students will create a graph (on the floor) to understand what a single sonar sensor can be expected to detect.

<aside> 💡 For this activity, plug in the sonar sensor to port 1. The robot should be equipped with only one sonar sensor for this activity (see image below).

</aside>

For this activity, the robot should be equipped with a single sonar sensor (this is the default configuration of the robot). In this stock image, the sonar is plugged in to port 2 but we will use port 1 for this activity.

For this activity, the robot should be equipped with a single sonar sensor (this is the default configuration of the robot). In this stock image, the sonar is plugged in to port 2 but we will use port 1 for this activity.

Open the Sonar Directionality Program in Mblock 5 from the link below and connect to your robot using the dongle connection. See here for instructions on how to connect to the robot.

sonar_directionality - mBlock Community

<aside> 💡

Clicking the link to the program will open the mBlock website. To see the actual program, click Source at the bottom left of the page that opened.

You can use the program in the online version of mBlock or download it to your computer by selecting File and Save to your computer. The downloaded program can then be edited using mBlock if installed on your computer.

See Step 1: Open the example program for an example and more instructions.

</aside>

The program is straightforward: It continuously measures the distance from the sonar and checks whether the returned value is smaller than 400 cm. If nothing is detected, the sensor returns a value of 400 cm. If the sensor detects something, the green LEDs on the robot are switched on. If nothing is detected, the red LEDs are switched on. Therefore, the robot’s color should indicate whether the sonar picks up an echo.

To measure the region in which the robot can detect an obstacle, place the robot in a large open space (see image below). Next, move an obstacle in front of the robot (in this case, a black pole) to find the largest distance at which the object is detected (the robot turns green) for several directions. While doing this, ensure that the robot is not picking up echoes from your body. In all likelihood, your body will be a larger object than the one you use to assess the sonar’s reach.

Untitled

In trials for this lesson, a black plastic tube pole was used as the obstacle, and straws (or tape) were placed on the floor, connecting the positions at which the robot could detect it. For every position in the area delineated by the straws, the robot could detect the tube pole (the robot turned green). Moving the tube pole outside this area turned the robot red.

You could repeat the measurements with different objects and compare the resulting patterns.

Questions