Download presentation
Presentation is loading. Please wait.
Published byClaire Berry Modified over 6 years ago
1
Selection Learning Objective: to be able to design algorithms that use selection.
2
Right Motor Forward Off
Selection With selection different sets of instructions are executed depending on the result of a condition. Here is an example of an algorithm that uses selection: Start Right Motor Forward On Left Motor Forward Off Left Motor Forward On Right Motor Forward Off Button A Pressed? Button B Pressed? Yes No LOOP IF ButtonA.pressed THEN RightMotor.forward(off) LeftMotor.forward(on) ELSEIF ButtonB.pressed THEN LeftMotor.forward(off) RightMotor.forward(on) ENDIF ENDLOOP
3
Predict what this program will do:
Activity 1 Here is the program code for the algorithm given on the previous slide. Predict what this program will do: Prediction: Now write this program and test it on Bobbot.
4
Activity 2 LOOP IF ButtonA.pressed THEN ELIF ButtonB.pressed THEN
Design an algorithm in pseudocode that makes Bobbot move in different patterns of your choice when buttons A and B are pressed. LOOP IF ButtonA.pressed THEN ELIF ButtonB.pressed THEN ENDIF ENDLOOP
5
Place a screenshot of your code here:
Activity 3 Use the Mu editor to create the program you designed in activity 2 and test it on Bobbot. Place a screenshot of your code here:
6
Line Sensor Bobbot is fitted with a line sensor that can be used to detect whether the surface it over is light or dark. LOOP IF LineSensor.light THEN Display(“L”) ELSE Display(“D”) ENDIF ENDLOOP
7
Predict what this program will do:
Activity 4 Here is the program code for the algorithm given on the previous slide. Predict what this program will do: Prediction: Now write this program and test it on Bobbot.
8
Activity 5 LOOP IF LineSensor.light THEN ELSE ENDIF ENDLOOP
Design an algorithm in pseudocode that makes Bobbot follow a dark line by turning right if it is over a light surface and turning left if it is over a dark surface. LOOP IF LineSensor.light THEN ELSE ENDIF ENDLOOP
9
Place a screenshot of your code here:
Activity 6 Use the Mu editor to create the program you designed in activity 5 and test it on Bobbot. It should make Bobbot follow a dark line. Place a screenshot of your code here:
10
Extension (Part A) Design an algorithm that will make Bobbot move in a zig zag pattern if button A is pressed and follow a line if button B is pressed.
11
Place a screenshot of your code here:
Extension (Part B) Use the Mu editor to create the program you designed on the previous slide and test it on Bobbot. Place a screenshot of your code here:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.