available at: 5.1 program functions for vex robots program functions for vex robots

11
ailable at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots Program Functions for VEX Robots

Upload: annabella-skinner

Post on 18-Jan-2018

215 views

Category:

Documents


0 download

DESCRIPTION

Available at: 5.1 – Program Functions for VEX Robots Functions  A function is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code?

TRANSCRIPT

Page 1: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Program Functions for VEX Robots

Page 2: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Program Functions for VEX Robots

Performance Objective: Using a bumper switch, line follower, and potentiometer, program functions to allow a robot to follow a line, touch a wall, raise a crane and then terminate.

Enabling Objectives: describe the purpose and benefits of a function match associated terms that define and describe functions describe why functions are used functions create code that develops a function draw a flow chart for using a bumper switch, line follower,

and potentiometer

Page 3: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Functions

A function is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code?

Page 4: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Functions

Functions allow you to reuse code rather than retyping a group of commands

Functions allow you to group a series of steps under one name.

Page 5: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Creating Functions

Navigate to the menu item project and select Add New Function from the drop down menu.

Page 6: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Creating Functions A dialog box will appear which

allows configuration of the function. This dialog box will allow us to name the function.

Type line follower for the functions name and Select OK.

Your done, you have create your first function. Now all you have to do is call the function.

Page 7: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Creating Functions Select the (tab/function) you

just created, titled linefollow. Now enter the code that allows the line follower to operate.

To the right is an example of code to operate the line follow sensor. If you

need assistance, please refer to lesson 3.6

Page 8: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Calling Functions Since our function now has code inside, we are ready to call

the function from the autonomous mode/function tab. Drag the function object into the path between variables

and End and a dialog box will appear asking you configuration settings. Click OK and you have called a function

Page 9: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Function Logic Drawing a flow chart only requires a slight

modification to what we have learned so far.

Page 10: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Function Logic If you notice on the right, we have a normal flow chart

but notice where the function is being called drive forward. To the left is the function/mode autonomous where we call the function

Page 11: Available at:   5.1  Program Functions for VEX Robots Program Functions for VEX Robots

Available at: www.etcurr.com Lesson 5.1 – Program Functions for VEX Robots

Try it out

Using a bumper switch, line follower, and potentiometer, program functions to allow a robot to follow a line, touch a wall, raise a crane and then terminate