available at: 5.1 program functions for vex robots program functions for vex robots
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
Available at: www.etcurr.com Lesson 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
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?
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.
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.
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.
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
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
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.
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
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