Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Waits, Loops and Switches

Similar presentations


Presentation on theme: "Using Waits, Loops and Switches"— Presentation transcript:

1 Using Waits, Loops and Switches
please!

2 Waits, Loops and Switches Pre-Quiz
1. In programming, what is a loop? When is a loop useful? 2. How can you control the duration for which a loop repeats? 3. In programming, what is a switch? Center for Computational Neurobiology, University of Missouri

3 Waits, Loops and Switches Pre-Quiz
Answers 1. In programming, what is a loop? When is a loop useful? A loop is an operator that allows us to repeat a set of commands indefinitely. Loops are useful when you need to repeat a set of commands multiple times. 2. How can you control the duration for which a loop repeats? You can control how many times a loop repeats by clicking the dropdown arrow next to “Control” on the loop block and setting it to forever, time, sensor, count or logic. 3. In programming, what is a switch? In programming, a switch is an object that gives different commands depending on the state it is in. Center for Computational Neurobiology, University of Missouri

4 Wait Block Activity Objective: Combine wait blocks, loops and switches to perform a task Do This: First, attach 2 touch sensors (name them A and B) Then program the robot to perform the following task: Stay at rest and display “Ready” on the screen. Move left and display “Forward” whenever touch sensor 4 is pressed. Move right and display “Reverse” whenever touch sensor 1 is pressed Stay at rest and display “Stop” when no buttons are pressed. ***Hint: Click on the icon, drag the block into the program, and select “Text” from the dropdown menu to display text on screen.

5 Wait Block Activity Solution
10 11 4 6 7 1 2 3 5 8 9 12

6 Wait Block Activity Solution
various settings

7 various settings (continued)
Wait Block Activity Solution 5 6 7 various settings (continued)

8 various settings (continued)
Wait Block Activity Solution various settings (continued) 8 9

9 various settings (continued)
Wait Block Activity Solution various settings (continued) 10 11

10 various settings (continued)
Wait Block Activity Solution various settings (continued) 12

11 Waits, Loops and Switches Post-Quiz
1. In programming, what is a loop? When is a loop useful? 2. How can you control the duration for which a loop repeats? 3. In programming, what is a switch? Center for Computational Neurobiology, University of Missouri

12 Waits, Loops and Switches Post-Quiz
Answers 1. In programming, what is a loop? When is a loop useful? A loop is an operator that allows us to repeat a set of commands indefinitely. Loops are useful when you need to repeat a set of commands multiple times. 2. How can you control the duration for which a loop repeats? You can control how many times a loop repeats by clicking the dropdown arrow next to “Control” on the loop block and setting it to forever, time, sensor, count or logic. 3. In programming, what is a switch? In programming, a switch is an object that gives different commands depending on the state it is in. Center for Computational Neurobiology, University of Missouri

13 Vocabulary brainstorming: Thinking of ideas as a group.
iteration: Doing something again, especially with the intent to make improvements. loop: An operator that repeats a set of commands. switch: In programming, a switch is an object that gives different commands, depending on the state it is in. Center for Computational Neurobiology, University of Missouri

14 Images Sources Slides 1: wall switch drawing; source: Microsoft® clipart: us/images/results.aspx?qu=light+switch&ex=1#ai:MC | Device and programming images from LEGO MINDSTORM NXT User’s Guide Screen captures, diagrams and drawings by author Center for Computational Neurobiology, University of Missouri


Download ppt "Using Waits, Loops and Switches"

Similar presentations


Ads by Google