Using the ultrasonic sensor

Students will explore the capability of Otto to measure distance and display lights with the ultrasonic sensor.

Materials required

  • Using the ultrasonic sensor slides 
  • Otto Starter robot or only the circuit board with the ultrasonic sensor 
  • Computers with internet and/or bluetooth connection 

Learning Objectives

  • Identify the key components of a robot and explain their functions. 
  • Recognize robotic systems in everyday life and be able to reason about how they help. 
  • Know that robots use algorithms to perform tasks.
  • Write and upload programs that control the robot. 
  • Understand key concepts of programming (loops, conditionals, variables, and functions) and apply them to write effective programs for the Otto robot.
  • Identify the problem to be solved and develop a plan to address it using the Otto robot components. 
  • Use an iterative design process to improve the robot’s performance.
  • Create a project that combines robotics with another creative discipline. 

How can Otto see stuff?

Start the activity by asking students to share their ideas about how Otto can use its “eyes” to actually see stuff. If students already know the name of the sensor, another good question can be “how do you think that ultrasonics work?” 

Encourage students to share any idea they could think about! 

In the second slide, it briefly specifies that Otto can effectively “see” stuff, but not exactly in the same way that we, humans, do. 

The next slide provides a concise explanation of how the ultrasonic sensor operates. As a teacher, you have the freedom to expand upon this explanation using your own resources. 

Activity: coding the ultrasonic sensor

In case that students still don’t know it, in this activity they will discover that the ultrasonic sensor, besides measuring distances, can also display lights. Going to webcode, allow students to connect their Ottos and make the code in the slide to try out how the sensor works by displaying green lights when the sensor detects something in less than 20 cm, and keeping lights off when it is nothing in less than that distance. 

10-1_test-ultrasonic-light-measure.otto 

 

Once each student has tried the code and verified its functionality, the teacher can ask them to explain why the code works. This exercise encourages students to understand the logic behind the code and reinforces their comprehension of how the components interact to achieve the desired outcome.   

Confirming that the sensor work

If it is the first time that students use the ultrasonic sensor, it could be a great idea to confirm that it is effectively measuring distance by using a ruler or another measuring instrument to confirm that the detection is actually happening when the distance get less than 20 cm.  

Challenge: Zones Lights

In the last slide, we introduce a small challenge for students called “Zones Lights”. By measuring distance with the ultrasonic sensor, Otto must determine if an object is in a safe, warning or dangerous zone. The closer the object is, the more dangerous the area. 

ℹ️ There is a small intentional “mistake” in the challenge definition to expand the activity.  

The definition of the challenge propose to code the robot for the next distances:  

🟢 when the distance is equal or greater than 80 cm 
🟡 when it is less than 50 cm 
🔴 when it is less than 20 cm 

Here are two possible solutions for the challenge: 

This one implements if + else if blocks  10-2_zone-lights-1.otto 

This one works with multiple if statements instead 
10-2_zone-lights-2.otto 

If we look carefully, there is a gap between 50 and 80 cm. In the code, we didn’t explicitly tell the robot what it should do when an object is between 50 and 80 cm, so… what will the robot do?

Another solution that could be proposed is this one: 10-2_zone-lights-3.otto

The difference between this one and the two previous ones is that here we are covering the 50 to 80 cm gap by triggering the else block and displaying the red color. Since it is an else block, it will be activated under any condition that is not defined above. 

Depending on how the students made the code, their robots could handle this gap in different ways, in most of the cases it will keep the previous color it has shown (yellow or green).  

Activity expansion

  • This last activity could be expanded by adding extra challenges to students like: 

    • Debate about the question: what will the robot do when the distance is between 50 and 80 cm? and allow students to propose ideas to handle that gap.

    • Add more components to the code. If students already know how to use the other components of the robot (buzzer, color lights, motors) they could also add them to this code.  
Nach oben scrollen
Sie werden nach der Produkteinführung verfügbar sein.