Programming the monkey
Lego WeDo – Mechanisms and Machines - Lesson 5
Objectives
- To combine several mechanisms in a single machine build
- To understand and use loops, randomisation and sensors in an algorithm
- To use a range of inputs to start an algorithm that controls a machine
Lesson Resources
Lesson 1 - Motors, gears, and gearing down
Lesson 2 - Idler gear, Crown gears and Cams
Lesson 3 - Pulleys, Levers and Sensors
Lesson 4 - The Drumming Monkey
Lesson 5 - Programming the monkey
Lesson 6 - Build it yourself
Introduction
Recap the drumming monkey build from last week. What mechanism did you find? How did the model work?
The cams are a key part of the model as they lift the levers which create the drumming arms, but what happens when the configuration of the cams are changed?
Challenge
For this part the students can adapt their model by adjusting the cams and adding extra cams (there should be 4 in total in your WeDo box) to their model. They need to consider what effect it has on the drumming motion of the monkey.
Ask them to note their findings on the second side of the Monkey Drummer Investigation sheet.
Coding recap
Last lesson we only used a very basic algorithm to create the motion so we could analyse the cams. This week we are going to focus a little more on the programming for their model.
Check students are aware that they can start a program by pressing a key, instead of always using the ‘go’ button. If you can’t already see the full palette of programming blocks, click the small arrow in the bottom left of the screen and it should appear. They key start block is shown below. To change the key being used, drag a block onto your canvas, hover your mouse over the block so the mouse cursor becomes a ‘T’ and then just press the key you want to use on your keyboard.
Recap some of the other programming blocks, letting them investigate if necessary:
- How do you set the speed of the motor?
- How do you make the motor stop after 5 seconds? (10 = 1 second in the WeDo input blocks, 50 = 5 seconds)
- How do you play a sound?
- How do you randomise something? (Dice block) Try randomising the speed of the motor or the sound that is played.
- How can you repeat a sequence? What is the difference between a repeat block with no input and a repeat block with a number input?
Ask them to look at the following four algorithms (on teacher presentation slide 41). Choose one of them and with a friend, discuss how they think the algorithm will work and what will happen when it runs.
- What does the wait block do?
- How can you use sensors in your algorithm? (remember to add and plug in the sensor!)
-
- Waits for the motion sensor to be activated then runs the motor blocks.
-
- Waits for the tilt sensor to be shaken each time before playing a random sound
-
- When you press A it sets the power to 4, turns the motor clockwise. After the motion sensor has been activated (passed over) 3 times the motor will stop
Ask the students to write two or more algorithms of their own that begin when different keys on the keyboard are pressed.
Their algorithms must include:
- Movement
- Sound
- A speed setting
Their algorithms might include:
- A repeating block
- Randomisation blocks
- Waiting blocks
- A sensor