STEMLabs V5
To Do, or Not To Do Student

# Programming with Conditionals - Text-based

Materials Required:
Quantity Materials Needed
1

VEX V5 Classroom Starter Kit (with up-to-date firmware)

1

1

Engineering Notebook

1

Clawbot (Drivetrain 2-motor, No Gyro) Template

The Clawbot is ready to make decisions!

During this exploration you can access help right in the VEXcode V5 program.

Before you begin programming with conditionals, read the VEX Library Article explaining If Then Else Statements. The article can be found here.
For a list of operators to use in the If Then Else statements, read the VEX Library Article explaining Booleans. This article can be found here.

### Step 2: Let's start programming with conditional statements.

• Open the Clawbot (Drivetrain 2-motor, No Gyro) template example project.

• Build the project below.

Do the following in your engineering notebook:

• Explain what the project has the Clawbot do. You will need to explain more than the fact that it creates a stop button. Explain which instructions make the Clawbot do what.

• Write a one sentence summary that captures what the project does.

• Test to see if your prediction of what the project has the Clawbot do is correct.

• Save and download the project as CreatingAStopButton to Slot 1 on the Clawbot, and then run it.

• Check your explanations of the project and add notes to correct them as needed.

### Step 3: Understanding the wait until() statement.

Notice that if the Brain's screen is pressed, the flow of the project moves quickly and the project will move to the next instruction, which is the Drivetrain.stop() instruction.

Thus, the project needs a waitUntil() instruction that tells the robot to remain stopped until the Brain's screen is released. Otherwise, the forever statement would cause the project to begin again.

The waitUntil() instruction is necessary because of the speed of the project's flow. If it was not there, the project would move to the next instruction before the robot ever had time to respond.

### Step 4: Change the project.

Our next step is changing the if then statement to an if then else statement.

• Start by saving CreatingAStopButton as the new project, StopOrDrive.

• If you need help saving a project, click here for Python or for C++.

• Then build the StopOrDrive project shown below.