Activity 3.1.5 Variables and Functions VEX – Procedure Part 1: Using a variable to loop n times Open the PLTW ROBOTC template. Click File, Save As, select the folder that your teacher designated for you to save your ROBOTC programs in, then name the file A3_1_5_Part1. In this activity you will use the green LED, right motor, and bumper switch. Leave the previously connected motors and sensors wired to the Cortex. Go to the Motors and Sensors Setup window. Configure the Motors and Sensors Setup to reflect the inputs and outputs to be used. Note that additional motors and sensors that are physically attached may be configured; however, these are not required to be configured. Click OK to close the window. Cortex Wiring Diagram Use the program below in the section of the program between the curly braces. task main() int motorCount; motorCount = 0; while (motorCount < 3) { startMotor(rightMotor, 95); wait(2); stopMotor(rightMotor); wait(2); motorCount = motorCount + 1; } Save the program, power on the Cortex, compile, and download the program. If you have any errors, check with your instructor to troubleshoot your program. Press Start to run the program and observe the behaviors. Document what this program would look like as pseudocode simple behaviors. Create a program that will run a motor back and forth 20 times, 0.5 seconds each way. Test the program and troubleshoot until the expected behavior has occurred. Make sure your code is documented with a task description, pseudocode, and line-by-line comments. Save the program as A3_1_5_Part1_2. You will reuse this program in Activity 3.1.6. Part 2: Using a variable to remember a maximum or minimum value and Using debugger windows Open the PLTW ROBOTC template. Click File, Save As, select the folder that your teacher designated, and then name the file A3_1_5_Part2. Use the program below in the section of the program between the curly braces. task main()
Activity 3.1.5 Variables and Functions – VEX Procedure Part 1: Using a variable to loop n times Open the PLTW ROBOTC template. Click File, Save As, select the folder that your teacher designated for you to save your ROBOTC programs in, then name the file A3_1_5_Part1. In this activity you will use the green LED, right motor, and bumper switch. Leave the previously connected motors and sensors wired to the Cortex. Go to the Motors and Sensors Setup window. Configure the Motors and Sensors Setup to reflect the inputs and outputs to be used. Note that additional motors and sensors that are physically attached may be configured; however, these are not required to be configured. Click OK to close the window. Cortex Wiring Diagram Use the program below in the task main() section of the program between the curly braces. int motorCount; motorCount = 0; while (motorCount < 3) { startMotor(rightMotor, 95); wait(2); stopMotor(rightMotor); wait(2); motorCount = motorCount + 1; } Save the program, power on the Cortex, compile, and download the program. If you have any errors, check with your instructor to troubleshoot your program. Press Start to run the program and observe the behaviors. Document what this program would look like as pseudocode simple behaviors. Create a program that will run a motor back and forth 20 times, 0.5 seconds each way. Test the program and troubleshoot until the expected behavior has occurred. Make sure your code is documented with a task description, pseudocode, and line-by-line comments. Save the program as A3_1_5_Part1_2. You will reuse this program in Activity 3.1.6. Part 2: Using a variable to remember a maximum or minimum value and Using debugger windows Open the PLTW ROBOTC template. Click File, Save As, select the folder that your teacher designated, and then name the file A3_1_5_Part2. Use the program below in the task main() section of the program between the curly braces.
3.1.5.a.vex_variablefunction.docx