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

Trial Lesson Upper Elementary 60 minutes - Variables and Sensors

60 Minutes

Lesson Overview

Learners will explore events, measurements and objects that change in terms of size, value, or number over the course of time. We say that things that can change, vary. A variable is used to represent an amount, either when we are not sure what the amount is or when it can change.

Key vocabulary:
    Variables, Store, Values, Assign, Declare,

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
    Unknown block type "youtube", please specify a serializer for it in the `serializers.types` prop
  • Time for Practice
  • 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 "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
    • Cool Down
      • Extensions & Challenges
      • Extend
      • Support
        • Additional Reading
        • Trial Lesson Upper Elementary 60 minutes - Variables and Sensors

          60 Minutes

          Lesson Overview

          Learners will explore events, measurements and objects that change in terms of size, value, or number over the course of time. We say that things that can change, vary. A variable is used to represent an amount, either when we are not sure what the amount is or when it can change.

          Key vocabulary:
            Variables, Store, Values, Assign, Declare,
          • Knowledge of block values and repeats; experience with conditional statements
          • Tablet with Bluetooth 4.2+
            • Marty the Robot v2
            • Marty Workbook
            • Tablets
            • Access to the MartyBlocks editor

          Learning Objectives

          • Describe what a variable is.
          • Say why some programs use variables.

          This lesson will involve Marty walking and might be best to have Marty on the ground for all code tests.

          Warm-up

          Share with the learners a recipe for making a cake, the video shows how to make a cake in a mug using a microwave. Some measurements use the customary, or imperial, measurement and some use metric. There is no need to focus on the measurement types, the important part is the numerical value of each measurement; however, this could lead to a discussion on conversion if it is appropriate. Each measurement shows onscreen as the video plays.

          As learners watch, have them record the values for the recipe in their workbooks. Once complete, have learners calculate how much of each ingredient would be needed for two or more cake cups, support learners with the calculations as needed, the goal is more about thinking how the recipe amounts will vary - when I have two cakes I will double the ingredients, when I have three cakes I will treble them - rather than the actual amount at the end - 2 x 3 = 6 or 1/2 x 3 = 1 1/2.

          After the learners have completed the table, ask them what the variable was (the number of cakes). Reinforce that the variable is the number of cakes by explaining that as it changes, the total ingredients change but the types of ingredients for each cake do not change. The focus is not to define independent and dependent variables in this lesson, just to compute the new values for the total quantity of each ingredient.

          Get Learning

          The following video features Marty acting based on a variable. The variable counts the number of times a user taps a sprite in 10 seconds. Then, the program instructs Marty to take that many steps. The video below shows that the variable name is steps, this makes sense for this variable because the output will be Marty's steps. Encourage learners, when it comes to them declaring, or naming, their variables, to use a name that makes sense.

          Below is a sample of Marty using a variable and the code that instructs them.

          Have learners share their observations at the end. The video has this program run twice so that learners can see that the number of steps and sprite taps have both changed. The transitions are only to give Marty more screen space when walking.

          After viewing this video, have learners record the values for the variables in their workbook. Below is the process of setting the code to have Marty walk based on the taps.

          As a whole class, it would be good to model a variable and its changing nature affecting Marty. This could be done with the tapping, as demonstrated, or it could be showcased with a loop that increases Marty's step count or arm movement. There are example code blocks in the teacher guide that you could use to display this functionality.

          Time for Practice

          The workbook describes the task for the learners to complete for this lesson but there is information in the presentation that is useful for first steps with variables; additionally, the information is available in the section that expands, below.

          Variables have their own section in the MartyBlocks environment. The image in the presentation (below) shows where to find the variable section and the purpose of two of the blocks.

          The following image shows what happens after tapping 'Make a variable'.

          After tapping OK, learners will see a new block called Value, which is set to 0 for just now.

          This video shows learners how to find the variable section, and declare one for using with Marty, assign an initial value and change its value. This is a manual change rather than an automatic one, the earlier video of Marty walking had an automatic change. The video has no output through the physical Marty, the output is on the sprite Marty in MartyBlocks. The video stops before the green flag is pressed, have learners suggest what the Marty sprite will 'say' Discuss with learners what the output for a physical Marty could be: number of waves, kicks, steps, degrees for a movement, time taken for a movement, basically anything that is an argument in MartyBlocks for one of Marty's movements or looks.

          Learners need to have time to practice:

          • creating and setting a name for a variable
          • planning for how the variable will affect Marty
          • attaching the value for the variable to a different block.

          The workbook offers a series of guiding questions in order to have learners design a program to make use of variables with color detection, rather than focusing on numerical values. The teacher guide shows finished examples of the code learners could create, with explanations for what is happening.

          Cool Down

          Bring learners back together to discuss the challenges they faced and overcame. Have groups describe their creations and explain what is happening. If you can do so, model them on the trial Marty using each group's device. Encourage other groups to ask questions to deepen their understanding of the processes.

          Suggested questions you might ask:

          • What values can you think of, in your daily life, which are variables? temperature, time, speed, distance, mass or weight, emotion, energy levels, etc.
          • What difference do you think there would be if there were no variables for recipes - think of different cakes that require different quantities of ingredients - butter, sugar, salt? There would only be one recipe for cake: it would be a bit boring.
          • Which type of program do you think will be more interactive, one with or without variables? A program without variables will run the same way each time, there is, by default, no interactivity: you will not change the output of the program.

          Carry out any end of lesson routines.

          Log off devices and clear everything away.

          Extensions & Support

          Extend

          Challenge learners to think about what might happen if Marty detects a color they don't know. The two examples are 'air' and 'unclear'. Air is when there is nothing detected and unclear is when the color is not red, blue, green, purple or yellow.

          Support

          Variables may still be a very new concept for learners. The connection to real world example is crucial. This lesson uses recipes, with the number of cakes being a variable.

          Reinforce that the purpose of the learning is not to build a complex program with variable but rather just to describe what they are and change the declared value. Share with learners more examples of variable in their daily life to remove the stigma that 'variables are hard': learners will use and interact with variables on a daily basis without realising or thinking about it.

          Some examples of variables can include:

          • money in a savings account varies as you deposit or withdraw funds, and with interest
          • how much sleep you get each night can vary based upon how full your day is, how exciting your next day will be or other factors
          • amount of homework can vary based on the day of the week, the subject, the teacher, the time of year, and other factors

          Additional Reading


          • 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: 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)