2.15: Marty's Disco Feet Respond to Movement
Lesson Overview
In this lesson learners will extend their understanding of conditional statements (if statements) to practice with parallel programming: if an event occurs, carry out different actions in another part of the code.
Please read the knowledge base article about the Disco addons, if you haven't already.
- estimate, conditional / if statement, range,
Content Sections
2.15: Marty's Disco Feet Respond to Movement
Lesson Overview
In this lesson learners will extend their understanding of conditional statements (if statements) to practice with parallel programming: if an event occurs, carry out different actions in another part of the code.
Please read the knowledge base article about the Disco addons, if you haven't already.
- estimate, conditional / if statement, range,
- Knowledge of conditional statements, Logic statements, events and parallel programming
- Tablet with Bluetooth 4.2+
-
- Marty the Robot V2
- Marty Workbook
- Tablets
- Access to the Marty Blocks editor
- Disco Feet add on for Marty v2
- Protractor (optional)
Learning Objectives
- I can create code that coordinates two separate parts of Marty working at the same time.
- I can create conditional statements to display different output depending on an action.
Warm up
Have a recipe on the board, listing steps in sequence, for preparing pasta sauce and cooking pasta. Compare this with a second recipe that outlines parallel processes occurring, while preparing the pasta sauce and cooking the pasta.
Ask learners if there are benefits for both recipes or if one method is better than the other across the recipe. Record answers, which may include: doing things together is faster; doing things one at a time lets you focus on each step, which may lead to fewer mistakes; doing things together means that you are staying active through most of the recipe time; doing things together may make it harder to find out what was incorrect if the result is not what you expected.
Share the objectives and success criteria for today's lesson.
Share the examples of Marty making use of movement parallel processes; there are two which you can choose to show, if you only want to show one, delete the one you don't want. The code is not shown here, alongside the video before it would take up too much of the screen space. Please consult the teacher guide to see the code, with an explanation, and the location of the blocks.
Get Learning
At this point, everyone should have MartyBlocks loaded, with Marty connected. Display the slide called 'The Disco blocks', from the presentation. They will notice that each of the three blocks has 'foot' showing and an arrow pointing down. Quickly revise that these are the same three blocks we used for the lesson on the disco eyes and arms, on this occasion we select the feet from the dropdown.
Have learners drag the three blocks onto the workspace and explore them. Show learners the next slide, a very basic block of code displaying all three of the blocks in action.
Learners will notice, again, that the script happens amazingly quickly. It doesn't change once it runs once and there are no conditions: on start, all the blocks run and they only run once. How do we have the code run more than once? A repeat block. How do we set a condition in the code? An if block. How do we have two processes running in parallel? If there are no answers - if they don't remember, ask how we set up for a program, with a single sequence - add an event block. How might we do it for more than one sequence, at the same time? Two or more event blocks.
Display adding two event blocks to the workspace. Run two simple commands that show different parts of Marty working. Show what happens when you try to program the same part of Marty to do two different things, at the same time - the commands run one after the other. Ask why there might be a problem with this.
Marty could look something like this, with the code from below.
Have learners explore using two event blocks to create some code with parallel processes. Encourage learners to share results and insights into the work that they did.
Time for Practice
Learners will need to create a program that allows for different actions to occur in parallel, using conditional blocks to determine when lights show on the disco feet add-ons. Learners need to think about:
- how to control for different events: if a specific action occurs, do one thing; if a different action occurs, do a second thing; if both actions occur together, do a third (different) thing
- what is needed to account for the different eventualities: an if block can handle one event and a second if block can handle a second different event, but having two events combined requires more thought - this will require either the use of an AND statement or a nested loop.
- the lights need to know when the arms are moving. The if statements will need to be able to 'sense' the arms' positions.
- the arms need to be told to move. This will require different event blocks.
Have learners use their workbooks to think about what actions they do in life that are good to do in parallel with other actions and which things they do that are best to do in isolation, some examples are in the workbook. Have them continue to use the workbook for planning, before working on MartyBlocks.
For planning the code, the following blocks are recommended:
For the samples for this lesson, I used the 'wave' block to move the arm but learners could use the 'move joint' or another movement block that causes a value to change, to create a similar result. I have suggested other blocks that would accommodate this detection of movement, above. Learners will need to experiment with which joint changes when a movement occurs: wave causes the arm position to change, but so do dance and wiggle.
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 don't interfere?
- How test to check if 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 explore the different displays from the presentation:
- What setting might cause Marty to light all lights when both arms are raised for one script but only light one region for another script?
- Challenge learners who have created the feet lights with the logic block to consider using nested conditionals, and vice versa.
Support
Have example pseudocode for situations where logic (AND) can be used to make a choice and when nested conditionals can be used. Compare the results and see if you can apply that to the rhinking about the disco feet.
Additional Reading
- 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
- Literacy & English: Writing
- Computing, Design and Technology: Design and Technology
- Computing, Design and Technology: Computing
- CSTA Education Standards
- Digital Technologies, Design & technologies: Digital Technologies
- International Society for Technology in Education (ISTE)