3: Marty Sensing the Environment
Step 3 of 5: 2.21: Estimating with Distance Sensors
Use Marty's distance sensors to trigger a response when someone walks past!

19 of 19 linked standards shown.
| Curriculum area | Linked standards |
|---|---|
| Digital Technologies, Design & technologies: Digital Technologies |
Select a code to read the full standard.
| Curriculum area | Linked standards |
|---|---|
| General standards |
Select a code to read the full standard.
| Curriculum area | Linked standards |
|---|---|
| Health and Wellbeing: Mental, Emotional, Social and Physical Wellbeing | |
| Literacy & English: Listening and Talking | |
| Literacy & English: Writing | |
| Numeracy: Number, Money and Measure | |
| Technologies: Computing Science |
Select a code to read the full standard.
| Curriculum area | Linked standards |
|---|---|
| Computing, Design and Technology: Computing | |
| Computing, Design and Technology: Design and Technology |
Select a code to read the full standard.
| Curriculum area | Linked standards |
|---|---|
| International Society for Technology in Education (ISTE) |
Select a code to read the full standard.
| Curriculum area | Linked standards |
|---|---|
| Middle School Technology Applications: Grade 6 to Grade 8 |
Select a code to read the full standard.
In this lesson, students are introduced to the infrared (IR) distance sensor, like the add-on available with Marty v2. These sensors allow Marty to measure the proximity of objects using beams of IR light. The applications of IR sensors in the real world are discussed before students are invited to write a program in which Marty responds to a person walking past him, in addition, learners will code different responses according to the sensed distance and learners will estimate how far away something is.
Please read the knowledge base article about the distance sensor add-on, before engaging with this lesson.
Experience using sensors with Marty
Have Marty, or Martys, set up at the entrance to the door. Have them set up to respond to learners that come within a certain distance. If using more than one Marty, program different responses when learners pass close enough. Ensure that you are not near a computer when the learners enter so that they can see you are not controlling Marty's response.
Ask learners what they witnessed as they entered. Ask for suggestions they can think about when machines move 'automatically'. Responses might include automatic doors, security lights, speed cameras (speed traps). Ask learners for suggestions as to what the displayed machines have in common. Distance sensors may be suggested, if not, highlight the machines that do have distance sensors and ask what causes them to function/move.
If distance sensors are suggested now, discuss with the class what they are and how they might work. The definition of a distance sensor is in the teacher guide, as well as a simple explanation as to how they work. For more details, see the link in the "Additional Reading" section.
Invite learners to consider devices that use distance sensors. Some examples are included in the slides. Using these as inspiration ask the learners to think of what they could use Marty's distance sensors for.
Ask how they think Marty was able to change as learners moved closer or farther away. What code do we need to tell Marty to do different things when an action occurs? Hopefully learners will suggest an if statement, or conditional statement. If they do not, prompt learners with reminders from previous lessons than involved conditionals.
Share with learners where to find the block for the distance sensor and identify the physical sensor on Marty so that they can see the part of Marty that sends and receives the signal. To more fully engage the learners, it is possible to install the sensor with the class, each group having responsibility for attaching the sensor to a Marty.
Have learners tick the box beside the sensor so that they can see the sensor's range, accuracy and speed with which the information updates.
Display the video of Marty using the conditional statement to react to something at a certain distance.
Compare how this sensor works with the obstacle sensor: the distance sensor is able to specify the distance has to be in order to trigger an action, the obstacle sensor is only able to determine if something is in the way or not, and that something has to be very close.
Highlight the fact that only one action occurs and it only occurs once. Encourage learners in their group to plan for more opportunities. After some ideas about a lack of repeat blocks, or some other way of looping the information, ask learners about how far away they think the object was that caused Marty to react. Draw attention to the conditional statement and what the value was, next to the inequality. This allows us to make an estimation about the distance from Marty that the object is.
To familiarise the class with the distance sensors and check they are working as expected, ask them to record the maximum(approx 1700mm) and minimum (39mm) values Marty's distance sensors can report in their workbooks. By measuring the distances for themselves, the learners will get a feeling for the scale over which the distance sensors operate in the real world.
Ask learners to begin planning for two things: what is Marty going to do as a response, the action; when is Marty going to respond in a specific way, the distance that triggers the response. Have learners share their ideas once you have given groups time to plan.
In their groups, learners will need to test values to find if the conditions for movement are reasonable. This will fulfill two goals: it will give learners a chance to estimate distances in millimeters, or convert to another unit, and it will reinforce the need for trial and error in development until they reach a satisfactory result.
Give learners ample opportunities to test their code using different static objects and moving objects, running the code when the object is already a set distance away and when the object moves, perhaps triggering more than one reaction from Marty.
The range from closest to farthest allows for several conditions and reactions from Marty.
Bring learners back together to discuss the challenges they faced and overcame. Have groups model their creations and explain what is happening, when. Encourage other groups to ask questions to deepen the understanding of the processes.
Suggested questions you might ask:
Carry out any end of lesson routines.
Log off devices and clear everything away.