1, 2, 3, code ! - Cycle 2 activities - Lesson 3.5. Understanding sensors to program Thymio

Summary

VPL programming for Thymio is event-driven: students will learn how to use Thymio's sensor status to trigger precise actions.

Key ideas
 (see Conceptual scenario)

 "Robot"

  • A robot has sensors that let it perceive its surroundings.

"Algorithms"

  • A test indicates which action to perform when a condition is met.

Equipment

 

For each group

  • A Thymio robot
  • A computer with VPL software

For each student:

Glossary

Sensor, event

Duration

1 hour

 

Starting the situation

In the previous lesson, the students programmed basic behaviors for Thymio: moving forward and changing color. But they also noticed that Thymio never goes back to its original setting. If it starts moving forward, nothing in its program tells it how or when to stop. The teacher restates this observation: when a sensor detects something, we say there is an "event"; for each event, Thymio verifies in its program if there is a test that gives it instructions to follow. In your opinion, can “detecting nothing” be an event?

 

Experiment: Detecting and not detecting (in groups)

The teacher gives students Handout 26. Each group will test the programs on the handout, making sure to delete the previous programs, and answer the questions.

Scientific note:
For the first time, students will see a program with more than one test (Program 5 has two tests). The two tests must be written one above the other for the program to be complete.

 

Group discussion

The class understands that VPL lets them write very precise tests, based on whether the sensors detect something (red icon), detect nothing (white icon) or if their setting isn't important (gray icon).

 

Conclusion and lesson recap activity

The class summarizes together what they learned in this lesson:

  • When a sensor detects something, we call this an event.
  • A condition can be "an event happened" or "an event has not happened" 

 

Further study

Faster students can apply this new information to complete the programs on Handout 25 (previous lesson):

  • Program 1: Add a test to make Thymio stop (e.g., when another button is pressed).
  • Program 2: Add a test to make Thymio’s cover not be green (e.g., it turns yellow) if it no longer detects anything in front of it.
  • Program 3: Add a test to make Thymio’s chassis not be blue if it no longer detects anything underneath it.

 

 


<< Lesson 3.4 Sequence III Lesson 3.6 >>

 

Project partners

Aucun résultats