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

3.05: Functions and the Noise Sensor

45 Minutes

Lesson Overview

In this lesson learners extend their use of noise sensors and their awareness of functions and variables. The program will use a variable and will move Marty in different ways, depending on the stored value. The opportunity to use nested conditional statements and loops also exists.

Please read the knowledge base article about the noise sensor addon, before engaging with this lesson.

Key vocabulary:
    sensor, loop, wait block, function, variable,

Content Sections

  • Learning Objectives
  • Warm up
  • Unknown block type "youtube", please specify a serializer for it in the `serializers.types` prop
  • Get Learning
  • Unknown block type "youtube", please specify a serializer for it in the `serializers.types` prop
  • Time for Practice
  • Cool Down
    • Extensions & Challenges
    • Extend
      • Support
        • Additional Reading
        • 3.05: Functions and the Noise Sensor

          45 Minutes

          Lesson Overview

          In this lesson learners extend their use of noise sensors and their awareness of functions and variables. The program will use a variable and will move Marty in different ways, depending on the stored value. The opportunity to use nested conditional statements and loops also exists.

          Please read the knowledge base article about the noise sensor addon, before engaging with this lesson.

          Key vocabulary:
            sensor, loop, wait block, function, variable,
          • Experience using sensors, functions and variables
          • Tablet with Bluetooth 4.2+
            • Marty the Robot V2
            • Marty Workbook
            • Tablets
            • Access to the MartyBlocks editor
            • Noise Sensor add on for Marty v2

          Learning Objectives

          • I can read and use the input from a sensor
          • I can create a variable that stores the value from a sensor
          • I can write a function that is triggered by a condition

          Warm up

          Begin by revising the purpose of function blocks. Have learners recall ideas from the recent lesson on the light sensor that featured function blocks. Ideas may include that function block tend to have only one purpose, different parts of a program can call the same function block, functions can call other functions. Inform learners that today they are going to be using sensors again, this time, a different level of noise is going to result in a different action.

          Have learners think of events in their lives where actions change depending on the level of noise in an environment: your neighbours may react differently, or may not react, depending on the level of noise; a teacher may respond differently depending on the noise in the classroom; a sportsperson or team might respond differently depending on the level of noise coming from the crowd, think of golf, snooker or football.

          Share the objectives and success criteria from the presentation.

          Have learners think of a person's response to noise based upon the situation. When is it good to be noisy, when it is good to be quiet? How do we react differently to different noise levels?

          Have Marty carry out the code in the video from the presentation, which involves multiple function blocks with different actions occurring, depending on the level of noise. The code is described in the teacher guide.

          Inform learners that the code that causes Marty to run relies on a variable. Ask which values might be stored as a variable, in this instance. Examples could include, the level of noise, the limits for the movement to occur. Ask if the learners noticed that the movements changed as the program ran, could they identify a change that occured in the program to trigger a different movement? Answers might include that the noise level changed. (The levels on the noise indicator in the video are not perfectly aligned to the sound, due to video editing that occurred.)

          Get Learning

          Remind learners of the noise sensor block so they can find a good range to use for measuring levels in the classroom. By clicking the tick box beside the noise sensor block, in the sensing section, learners can see a live display of the noise in the classroom. The values learners see can give them an idea of what quiet and noisy sounds like, they should record this to be the range of what Marty should use to react to the noise.

          Show the second video, of a basic movement with Marty responding to a noise. Also highlight that the action happens once and then stops. How can we address this? Loops, maybe, but where would the loop go?

          Give learners the time to work within their groups to plan what blocks they would use to allow for different movements based upon the noise sensed. Draw attention to the fact that unless you can somehow change the noise sensor value, Marty will only ever carry out one action. That would be boring for both you and Marty. The noise sensor will need to be used regularly, but it will also need to be stored so that it can be accessed at different times, in the program.

          Time for Practice

          Learners need to plan for how to recognise a change in the level of noise and incorporate function blocks to make sure a range of different sound levels are considered.

          Encourage regularly testing their code once they finish planning their work. Without periodically checking that the code is doing what is intended, work and time can be wasted because of the need to debug large blocks of code. This is another reason why having function blocks is a good idea: you can more easily spot where the bug is, if it occurs within a small function, when compared with a much larger block of code.

          Cool Down

          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.

          Take time to have group code displayed to the class, encourage observational questions from peers.

          Suggested questions you might ask:

          • How did you effectively use variables?
          • Where did you include function blocks to carry out all of the actions?
          • How did you decide to exit a function?
          • Did anything interfere with the classrooom noise? (It may be that Marty was picking up his own noise and responding to this)
          • Did anyone find a way to have Marty only listen to the classroom noise?

          Carry out any end of lesson routines.

          Log off devices and clear everything away.

          Extensions & Support

          Extend

          Challenge learners to have actions approximate the level of noise in the classroom:

          • Have Marty move a limb to display the level of noise in the classroom (the code in the teacher guide is broken down to explain how this is done)

          Challenge learners to use an additional variable(s), that way a different action can occur whether the current level of classroom noise is louder or quiter than it was on the last pass of the function.

          Consider including parallel code for example, sounds or actions from add-ons, depending on values from the variable that stores the noise sensor values.

          Support

          Have physical code cards available for learners to use, when building their scripts:

          • if/then and if/then/else blocks
          • loops
          • noise sensor blocks
          • operator blocks: <, >, =
          • a variety of movement blocks
          • function blocks

          Have a print out of the basic function statements, using the noise sensor.

          Encourage pseudo code to clearly outline what you want to happen based on certain results.

          • Technologies: Craft, Design, Engineering and Graphics
          • Technologies: Computing Science
          • Literacy & English: Listening and Talking
          • Health and Wellbeing: Mental, Emotional, Social and Physical Wellbeing
          • Literacy & English: Reading
          • Literacy & English: Writing
          • Middle School Technology Applications: Grade 6 to Grade 8
          • Computing, Design and Technology: Design and Technology
          • Computing, Design and Technology: Computing
          • CSTA Education Standards
          • Digital Technologies, Design & technologies: Design & Technologies
          • Digital Technologies, Design & technologies: Digital Technologies
          • International Society for Technology in Education (ISTE)