How to use the
Learning Portal

Learning Portal

Our hands-on, comprehensive lesson plans span a range of levels. Browse our free STEM and coding learning resources.

Marty Image

2.06: What's in Marty's Way?

45 Minutes

Lesson Overview

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.

Key vocabulary:
    Infrared, Sensor, Sense, Programming, BOOLEAN,

Content Sections

  • Learning Objectives
  • Warm Up
  • Unknown block type "youtube", please specify a serializer for it in the `serializers.types` prop
    Unknown block type "youtube", please specify a serializer for it in the `serializers.types` prop
    Unknown block type "youtube", please specify a serializer for it in the `serializers.types` prop
  • Get Learning
  • Unknown block type "figure", please specify a serializer for it in the `serializers.types` prop
    Unknown block type "figure", please specify a serializer for it in the `serializers.types` prop
    Unknown block type "youtube", please specify a serializer for it in the `serializers.types` prop
    Unknown block type "figure", please specify a serializer for it in the `serializers.types` prop
  • Time For Practice
  • Cool Down
    • Extensions & Challenges
    • Extend
    • Support
      • Additional Reading
      • 2.06: What's in Marty's Way?

        45 Minutes

        Lesson Overview

        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.

        Key vocabulary:
          Infrared, Sensor, Sense, Programming, BOOLEAN,
        • An awareness of loops and if / conditional statements, an understanding of BOOLEAN statements
        • iPad or Tablet with MartyBlocks
          • Marty the Robot V2
          • Marty Workbook
          • Tablets
          • Access to the MartyBlocks editor
          • Objects to use as obstacles

        Learning Objectives

        • I can create code for Marty to detect if an obstacle is there.
        • I can command Marty to react if there is something in the way.

        Warm Up

        Share 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.

        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.

        Get Learning

        Share 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 MartyBlocks 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.

        Share the code that will affect this movement. a suggestion for discussing what is in the code is in the presentation notes.

        Time For Practice

        Learners 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.

        Cool Down

        Bring 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:

        • What was interesting or challenging about using the obstacle sensor?
        • What modifications would you suggest for someone designing a new obstacle sensor?
        • Where are some other areas of our lives where an obstacle sensor could be a helpful tool?

        Carry out any end of lesson routines.

        Log off devices and clear everything away.

        Extensions & Support

        Extend

        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.

        Support

        Provide 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:

        • Marty walks forward (how do we make Marty take another step)
        • Marty continues to walk forward until the sensor alerts Marty (how do we tell Marty what to do if something is detected)
        • A different action occurs (how do I code the different actions that could occur)

        Additional Reading


        • Technologies: Computing Science
        • Literacy & English: Listening and Talking
        • Health and Wellbeing: Mental, Emotional, Social and Physical Wellbeing
        • Numeracy: Number, Money and Measure
        • Literacy & English: Reading
        • Literacy & English: Writing
        • Computing, Design and Technology: Design and Technology
        • Computing, Design and Technology: Computing
        • CSTA Education Standards
        • Elementary Technology Applications: Grade 3 to Grade 5
        • Digital Technologies, Design & technologies: Design & Technologies
        • Digital Technologies, Design & technologies: Digital Technologies
        • International Society for Technology in Education (ISTE)