Learning Portal

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

Marty Image

2.12 Building the Color Controller

45 Minutes

Lesson Overview

In this lesson learners will extend their knowledge of if statements to create code that will mimic Marty's Screen-Free mode.

In order to work with this lesson, each Marty will need to have a color sensor installed. Details about the color sensor can be found by clicking on this link.

Key vocabulary:
    sensor, if statement, conditional statement, repeat block, stop all,

Content Sections

  • Learning Objectives
  • Warm up
  • Get Learning
  • 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
        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
              • 2.12 Building the Color Controller

                45 Minutes

                Lesson Overview

                In this lesson learners will extend their knowledge of if statements to create code that will mimic Marty's Screen-Free mode.

                In order to work with this lesson, each Marty will need to have a color sensor installed. Details about the color sensor can be found by clicking on this link.

                Key vocabulary:
                  sensor, if statement, conditional statement, repeat block, stop all,
                • Experience using if statements, loops and the Controller
                • iPad or Tablet with MartyBlocks
                • Writing instructions, Maths direction language
                  • Marty the Robot V2
                  • Marty Workbook
                  • Tablets
                  • Access to the Marty Blocks editor
                  • Color Sensor add on for Marty v2

                Learning Objectives

                • I can use multiple if statements to command Marty to act.
                • I can improve on earlier code to make the result more accurate.

                This is recommended as a floor activity as it will require a degree of movement, from Marty.

                Warm up

                Show learners how to start Marty in Unplugged mode. This will allow learners to instruct Marty without making use of the app at all. Click here to see how screen-free coding works.

                Have learners experiment with the color cards or with other colored paper to see what Marty can 'recognise'. Ask learners to tell you the different commands that Marty performs as a response to the colors and make a record of this for learners to see for the duration of the lesson - this could be done on a board in the classroom or in the workbook for each group.

                Share with learners the objectives and success criteria for today's lesson.

                Get Learning

                Share with learners the video from the presentation or model a Marty with the code that is available below and in the Teacher's guide. If you choose to display with a physical Marty, ensure that learners hear you have turned on and turned off the Unplugged mode so they do not think you are cheating. Learners will see that the code is exactly the same as the screen-free color cards.

                Ask questions about how Marty 'decides' to move as he does.

                What do we need in code to have an action occur when something else happens, first?

                It is hoped that learners will suggest an if statement, or a conditional statement if you have introduced that vocabulary.

                If learners do not offer this, ask questions like, when do you go home? Answers might include,

                • "When the bell rings at the end of the day," or, "when it is (fill in the time)."
                • Ask them back, "So, if the bell rings at the end of the day, you go home?"

                Ask for other scenarios like this if you want to reinforce the need for 'if'.

                • When do you line up to come inside?
                • When do you tidy your desk?
                • When do we go to for PE?...

                Have learners remind you of the if statement - how it is composed - "If one thing happens, another thing will result."

                Show the code block for the color sensor and show the result as Marty stands on different color cards. Show the structure of the if statement so learners can see what is needed for the if statement to be used effectively. Share the additional blocks that would be helpful to result in an action occurring depending on a color.

                Share an example of Marty reacting to a color and performing an action. If modelling with your Marty, ensure that the robot is standing on the required color before running the program. If you change colors, nothing will happen; if you bring the initial color back, nothing will happen. Question what it is that stops Marty from moving again. Have them think together with their groups and use their discussion to inform their work, rather than answers in the whole group. The reason for nothing happening is because the program does not ask Marty to check again; for that, we would need a repeat block.

                Time for Practice

                Task learners to create code for one color, including that when the color is removed and returned Marty will move again.

                Once learners have discovered the necessity of the repeat lock, or other method for repeating the movement, have them expand their code to consider other colors and the necessary action. How can we ensure that different movements will happen when colors change but still check for all of the colors? Learners will need to have multiple if statements inside the loop forever block to accomplish this.

                Walk around the room to discuss where groups are in their work. Ask questions like, how does Marty know what to do with the color? What if the color changes? Do you have a command to stop the code or will it run forever?

                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 their 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 account for multiple colors and different actions?
                • How did you make sure Marty performed the same action if he detected the same color again?
                • Did you think of a way to code a stop for the program?
                • Did anyone find any other colors that Marty knows?

                Carry out any end of lesson routines.

                Log off devices and clear everything away.

                Extensions & Support

                Extend

                Challenge learners to modify the responses to the color to something different than the Unplugged coding commands:

                • The colors could signal a dance routine.
                  • There would still need to be some movement but they could all be 'walk forward' after completing the moves.

                Another possible challenge would be to use logic blocks:

                • If Marty detects blue or green complete an action.

                A further possible challenge would be to discover how many colors Marty detects and give each different color an action.

                Support

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

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

                Have a print out of the basic if statement for the green color.

                For learners who are challenged by estimation, encourage learners turn on Marty's Unplugged mode so that they can count the steps between the cards before assigning values to the movement blocks.

                Additional Reading

                Look at some of the lessons that use loops and conditional statements:

                Choices with an If Statements

                Using loops

                Additionally, please consult the instructions for installing the color sensor


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