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.19 Coordinating the Disco Lights with Parallel Programming

90 Minutes

Lesson Overview

In this lesson, learners will bring together their understanding of the disco light blocks and parallel programming to have multiple actions and multiple responses. Ideas presented here draw on the timing of the lights and responses to movements.

Please read the knowledge base article about the Disco addons, if you haven't already.

Key vocabulary:
    estimate, wait until, range, parallel,

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 "figure", 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
      • Cool Down
        • Extensions & Challenges
        • Extend
        • Support
        • Additional Reading
        • 2.19 Coordinating the Disco Lights with Parallel Programming

          90 Minutes

          Lesson Overview

          In this lesson, learners will bring together their understanding of the disco light blocks and parallel programming to have multiple actions and multiple responses. Ideas presented here draw on the timing of the lights and responses to movements.

          Please read the knowledge base article about the Disco addons, if you haven't already.

          Key vocabulary:
            estimate, wait until, range, parallel,
          • Knowledge of parallel programming, conditional statements and loops
          • Tablet with Bluetooth 4.2+
            • Marty the Robot V2
            • Marty Workbook
            • Tablets
            • Access to the Marty Blocks editor
            • Disco Eyes, Arms and Feet add on for Marty v2

          Learning Objectives

          • Plan code to make use of more than one event block, in parallel.
          • Use parallel blocks to move different parts of Marty at the same time.

          Warm up

          Read the story text from the resources about a party of adventurers exploring a castle. They come to a point in the story where there is a choice of turning left or turning right at a junction. Ask learners for possible actions they could take: turn left, turn right. The scenario will present a third choice of 'split the party' and go left and right. All three options will have 'consequences'. Read the choices learners suggest, they might suggest any of the three. Hopefully, they will suggest turn left or turn right, first and second; hopefully, they will suggest splitting the party, and going left and right, with the result being progression in the story. However, they might think that the adventurers are stuck. Ask questions about the party: how many people are in the party? Do they have to stick together? Are they able to think for themselves, maybe?

          Share the objectives and success criteria from the PowerPoint presentation and then display the example of Marty dancing with accompanying lights across feet, eyes and arms, the actions are coordinated meaning that the lights change with arm, eye and knee movements.

          Each of the code blocks is explained in the teacher guide. Discussing efficiency and debugging in coding is worthwhile. It is also worthwhile mentioning that even people at Robotical need to improve on initial code.

          The video and code aren't shown side by side here because it would be difficult to see the specific parts. The code is discussed in the teacher guide.

          Ask what they noticed, learners may suggest that the arms, legs and eyes move and the lights light up after Marty moves. Highlight that the example they are seeing is using separate event blocks, they are running in parallel.

          Get Learning

          This learning time should focus more on planning than writing the code. The program will be bigger than what learners have previously created so it makes a lot of sense for discussion and thinking to be longer than it has in past. Discuss as a class what blocks are essential for parallel programming:

          • learners must offer multiple event blocks,
          • actions or displays that do not conflict (arms for one event block, legs for a different event block),
          • keeping different blocks synced (using wait blocks when needed),
          • communication between blocks of code (if statements that trigger actions in other event blocks; this has been completed in the disco arms and disco feet lessons, or wait blocks that don't progress the code until something else happens).

          Display a second video that features the lights and movement not relying on each other.

          Ask learners what they see, this time. They may suggest the movement is much quicker because it only happens once. The lights only last as long as the movements because the repeat blocks match the length of the dance.

          Once enough feedback is given, by learners, show the next slide that contains four event blocks, one for a movement and 3 for each of the disco light add-ons: this is the code that makes Marty move like the video. Ask learners what they see. Suggestions may include:

          • There are multiple event blocks, so there is parallel programming
          • each of the light blocks repeats
          • the dance block is only used one time
          • everything starts at the same time
          • nothing overlaps

          The 'set all LEDs to off' sets all the lights to off, once the code completes. Without this, the lights will stay lit. This is a very helpful block to have for testing this code.

          Give time for learners to think about what they might like to have their Marty do, for a dance with the lights. Have groups share some of the ideas they are considering, allow for class questions and discussion around what will happen, how can it happen, where might it run slowly (if necessary)?

          Time for Practice

          When the discussion has sufficiently covered a wide range of areas, have learners begin planning out what the different event blocks will have 'responsibility for what is the goal for each event, one might control the lights for the feet, one might control the movement of the legs, etc. or, one might control all the lights or all the movements. This discussion, before coding, will allow for the consolidation of understanding of parallel programming, particularly when different class groups are taking part in the information exchange.

          It may be that the planning will not be complete after the first block of time for a lesson. Learners need to be sure to save any plans for their code, if they are using paper to record their plans, the plans need to be kept for the next session. If you have planned for a double block, allow for the planning to continue until learners can explain what they want to create and how they want to create it. Groups must be confident with their plan and should be able to summarise the eventuality of the code to you before any actual coding starts.

          As learners complete their planning, allow them to start writing and testing their code. Emphasize the usefulness of testing individual blocks to ensure that they return the desired result. Remind learners that testing single blocks makes it easier to find problems rather than initially testing events that are working in parallel.

          Below are some examples of blocks that might be used for this lesson.

          And this is the mix that could be used for learners to time their actions: disco music.

          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 questions about differences between the design of different groups' code. If a group chose to explore any extension activities, allow for time to explain this.

          Suggested questions you might ask:

          • How did you make sure that different actions didn't interfere?
          • How did you test, or check, to ensure the different actions could occur at the same time?
          • Which lights were your favorite to code with?
          • Can anyone think of ways to improve their code after looking at others' ideas?

          Carry out any end of lesson routines.

          Log off devices and clear everything away.

          Extensions & Support

          Extend

          Challenge learners to think of more than one routine for Marty: once part of the song passes, perhaps 4 or 8 bars, Marty changes his move / light display.

          Support

          Highlight the blocks with values that can be edited, particularly the repeat block, the movement block, the wait block. Model, with learners, the effect that changing these values can have on the outcome of the code. Encourage problem solving, trial and error is important to get things as you want. Mistakes are expected and should be welcome.

          • Middle School Technology Applications: Grade 6 to Grade 8
          • Technologies: Computing Science
          • Literacy & English: Listening and Talking
          • Health and Wellbeing: Mental, Emotional, Social and Physical Wellbeing
          • Numeracy: Number, Money and Measure
          • Literacy & English: Writing
          • 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)