Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 ©2006 INSciTE Lab Three Task: Move forward for 2 feet, turn right 90º repeat to complete a square path. End up exactly where you started.

Similar presentations


Presentation on theme: "1 ©2006 INSciTE Lab Three Task: Move forward for 2 feet, turn right 90º repeat to complete a square path. End up exactly where you started."— Presentation transcript:

1 1 ©2006 INSciTE Lab Three Task: Move forward for 2 feet, turn right 90º repeat to complete a square path. End up exactly where you started.

2 2 ©2006 INSciTE Lab 3 An Answer Move forward and turn 4 times to form a square.

3 3 ©2006 INSciTE Keep it Simple Strategies KISS #3: Variables #4: Parallel Sequences #5: Loops

4 4 ©2006 INSciTE KISS #4: Parallel Sequences Make two tasks that run independently. (Can you walk and chew gum?) One task lifts the arm. The other task heads for home. Click and drag a sequence beam, release here. Hold cursor here until it changes into a wiring tool.

5 5 ©2006 INSciTE KISS #5: Loops Loops are a control structure In other programming languages: For … Next Do loop n times Do... Until Do it. Unless some test, do it again. There are loops for Forever Every sensor (including time) Logic Count If your algorithm says something like: “Until the sensor reads x, keep doing this”, use a loop.

6 6 ©2006 INSciTE Simple Loop Convert this to something simpler using a loop

7 7 ©2006 INSciTE Combining Structures Outside Loop runs forever. Light Sensor Switch runs inside.

8 8 ©2006 INSciTE Compare that line follower to this one: Better Simpler. One motor changes speed. Faster. Worse Tight corners? Comparing Algorithms

9 9 ©2006 INSciTE Watching 3 Sensors Logical ORs combine results into a single True or False Outside Loop (Logical)

10 10 ©2006 INSciTE Comparing Structures Rework your algorithm to fit the structures. Loop Execute something until an event WaitFor Wait for one event, then continue. Switch Make a choice based on a sensor value at a given point in time. Be careful to make sure you will be watching for the event at the right time

11 11 ©2006 INSciTE Tricks and Tips Never wait for a sensor to be an exact value, always greater than or less than You could miss the event due to sampling rate For example, wait until rotation greater than 64 not equal to 64.

12 12 ©2006 INSciTE Lab Four Task: Move exactly one lap around an oval. (Black 2cm line on white paper)

13 13 ©2006 INSciTE Lab 4 An Answer Did you start by copying? Why not? Is building a robot like taking a test?


Download ppt "1 ©2006 INSciTE Lab Three Task: Move forward for 2 feet, turn right 90º repeat to complete a square path. End up exactly where you started."

Similar presentations


Ads by Google