3: Marty Sensing the Environment
Step 1 of 5: 2.06: What's in Marty's Way?
Use Infrared sensors to give Marty the ability to detect obstacles and respond to the environment

21 of 21 linked standards shown.
| Curriculum area | Linked standards |
|---|---|
| Digital Technologies, Design & technologies: Design & Technologies | |
| 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: Reading | |
| 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 |
|---|---|
| Elementary Technology Applications: Grade 3 to Grade 5 |
Select a code to read the full standard.
Until now, students have had to test out the number of steps that it will take Marty to walk a certain distance manually. However, using Marty's inbuilt IR sensors we can program them to detect obstacles in his path. In this lesson, students will explore how we can use IR sensors.
Instructions for installing the IR sensor can be found in the knowledge base, here.
An awareness of loops and if / conditional statements, an understanding of BOOLEAN statements
| Timing | Activity | Possible adaptations |
|---|---|---|
| — | Warm UpShare with learners what they have done, so far, to avoid Marty walking into an object. Learners could say estimate steps, test, adjust and re-test. Inform learners that today we will be introducing a sensor to remove part of the work from us. Share with learners video of some low and high-tech examples of distance sensors. This is a good example up until about 41 seconds, after this it is an advertisement for a charity. Have learners think about the purpose sensors serve for machines and some people and record ideas in their workbooks. Show a response from Marty upon approaching an obstacle. There are two videos of this occurring, Marty is set at a different distance from the wall, as a starting point for each, and the video is not edited to give a programmer time to change the number of steps. |
| Timing | Activity | Possible adaptations |
|---|---|---|
| — | Get LearningShare with learners an image of the IR sensor and a slide of how it works. Explain that the IR sensor gets feedback from light that reflects off the wall and that is how Marty 'knows' something is in the way. ![]() ![]() When it comes to Marty acting based on the response the sensor gives it is important to understand that the IR sensor only sends one of two messages, true or false. The sensor sends true when light reflects off an object and is received by the sensor. The sensor sends false when there is no reflected light received by the sensor. The sensor has to be very close to an object to return true. There is another sensor that can detect how far away an object is but the IR sensor is not able to do this. Learners may have already learner about something called BOOLEANs, these are types that take only two values, examples are 0, 1 or true, false. Have learners go to the sensing tab on Blocks and press the 'Foot obstacle sensed' block. If there is nothing directly in front of the left or right foot, this will return false. If there is something, it will return true. Learners will need to use the BOOLEAN values of true or false with their if statements to have Marty move. Share the following basic video of Marty. Marty walks two steps and makes a noise because an obstacle is detected. There are no loops, just a move and sound block that are each used twice. |
| Timing | Activity | Possible adaptations |
|---|---|---|
| — | Cool DownBring learners back together to discuss the learning that occurred. Have groups share their thoughts about code that relies on a person monitoring everything and code that is more autonomous - the code works so it should be able to run reliably without someone always watching it. Suggested questions you might ask:
Carry out any end of lesson routines. Log off devices and clear everything away. | — |
Ask learners what they think would cause Marty to do this. Suggestions could include that Marty bumped into the wall and stopped because of that or that the programmer discreetly stopped the program and started a different event block.
| — |
Share the code that will affect this movement. a suggestion for discussing what is in the code is in the presentation notes.

| — |
| — | Time For PracticeLearners may have noticed that the Marty from the second video was two steps from the wall, so taking two steps would result in the sensor returning true. Have learners test the code from the presentation from a greater distance. What can we do to ensure Marty reaches and detects an obstacle so that they can react to it? Learners may suggest using a repeat block but you could also say that they should keep their ideas within their group to encourage a greater diversity of responses. Give learners time to plan their movement and response to an obstacle. | SupportProvide supportive questions around how we have actions repeat, repeat block, how we have Marty do one action depending on what happens first if/then/else block. Emphasize that during the planning stage, learners think about what happens as the code executes:
|
Challenge learners to have Marty react differently if they detect two obstacles in a short period of time. The first video of Marty moving, from the presentation, illustrates the different responses he might have. Learners may choose a different sound or raising arms in exasperation. The goal is a different response.