STEM Labs
To Do, or Not To Do

Teacher Portal

Teacher Toolbox - The Purpose of this Activity

Programming with conditionals can be accomplished by using an [If then] block within a project.

This activity will introduce students to programming with an [If then] block as well as using sensing and operator blocks to have the robot check if the Brain Up button is pressed. If it is pressed, the Clawbot's arm will raise. This first introduction will lay the ground work for adding robot reactions to other buttons on the brain.

The following is an outline of what your students will do in this activity:

• Watch the Using Loops and If-Then-Else Blocks tutorial videos.

• Use the Clawbot (Drivetrain) template to build the ArmUp project provided and predict what the project does.

• View a flowchart to help explain the flow of the blocks in the project.

• Refine their explanations of what the ArmUp project does.

• Edit their project by adding a [Wait until] block.

• Stop and Discuss: Students will reflect on their predictions on what the project will have the Clawbot do compared to their actual observations.

Materials Required:
Quantity Materials Needed
1

VEX IQ Super Kit

1

VEXcode IQ

1

Engineering Notebook

1

Clawbot (Drivetrain) Template

Teacher Toolbox

For suggestions on teaching strategies for this section, review the Delivery column of the To Do, or Not to Do Pacing Guide (Google / .docx / .pdf).

The Clawbot is ready to make decisions!

This activity will give you the tools to program your robot with conditional behaviors.
The [If then] block is the main focus within the activity but other Sensing, Control, and Operator blocks are also used.

You can use the Help information inside of VEXcode IQ to learn about the blocks. For guidance in using the Help feature, see the Using Help tutorial.

Teacher Tips

If this is the student's first time using VEXcode IQ, they can also see the Tutorials in the toolbar to learn other basic skills.

### Step 1: Let's start with an understanding of loops and conditional statements.

Before you begin programming with conditionals, first watch the Using Loops and If-Then-Else tutorial videos in VEXcode IQ.

Start by watching the Using Loops Tutorial video in VEXcode IQ.

Then watch the If-Then-Else Tutorial video in VEXcode IQ.

### Step 2: Programming with conditionals.

We want to build a project that will raise the arm if the condition of the Brain Up button being pressed is true.

If the condition is false, the Arm Motor will stop. Let's explore building a project that uses a [Forever] block and the [If then] conditional block to program the arm.

• Open the Clawbot (Drivetrain) Template. For help, view the Using Example Projects and Templates tutorial video.
• Build the project below.
• Save the project as ArmUp. If students need help saving the project, refer to the Naming and Saving tutorial video in VEXcode IQ.
• Check to make sure the project name ArmUp is now in the window in the center of the toolbar.
• Predict what the project will have the Clawbot do in your engineering notebook. Explain both the user's and the Clawbot's behaviors.
• Test to see if your prediction of what the project has the Clawbot do is correct.
• Download the project to Slot 1 on the Clawbot, and then run it.
• Check your explanations of the project and add notes to correct them as needed.

Teacher Toolbox

The project that the students build above will not work as-is. A [Wait until] block is necessary because of the speed of the project's flow. If it was not there, the project will move to the next block before the Arm Motor ever has time to respond. Thus, the blocks will flow down to the [Stop motor] block and then start back at the top of the stack because of the [Forever] block that repeats all blocks contained inside of it. This will be explored and then explained to the students in the next step.

Teacher Toolbox - Stop and Discuss

Now that the students have tested the project, ask them how their predictions compared to their observations. Facilitate the discussion by asking the following questions:

• What seems to be happening in the project?

• Is the condition of the Up button being pressed only checked once?

• What do you think needs to be added to the project for it to work properly?

### Step 3: Understanding the [Wait until] block.

In the previous step, the project did not raise the arm successfully. View the following flowchart that explains the project flow. Notice that if the Brain Up button is pressed, the flow of the project moves so quickly that the project will move to the next block, which is the [Stop motor] block.

Thus, the project needs a [Wait until] block that tells the Arm Motor to keep spinning until the Brain Up button is released.

The [Wait until] block is necessary because of the speed of the project's flow. If it was not there, the project would move to the next block before the Arm Motor ever had time to respond. Thus, the blocks would flow down to the [Stop motor] block and then start back at the top of the stack because of the [Forever] block that repeats all blocks contained inside of it.

Let's explore changing the project by adding a [Wait until] block. The Arm Motor will now continue to spin until the Brain Up button is released. Once the Brain Up button is released, the project will continue to the next block, which is the [Stop motor] block.

The project will now first check the condition if the Brain Up button is being pressed. If the Brain Up button is being pressed (TRUE), then the arm will spin up until the Brain Up button is released. Once the Brain Up button is released, the project will move to the [Stop motor] block before returning to the top of the stack to begin again because of the [Forever] block.

If the Brain Up button is not pressed (FALSE), then the project will move to the [stop motor] block before returning to the top of the stack to begin again because of the [Forever] block and the arm will never spin.

Motivate Discussion

Q: When the wait until block is not used, what happens once the Brain Up button is pressed?
A: Because of the speed of the project flow, the project moves from the [Spin] block to the [Stop motor] block faster than the Arm Motor can respond. Thus, the arm does not move.

Q: What is the purpose of the wait until block in the project above?
A: The wait until block allows the arm to continue spinning up until the Brain Up button is released.

Q: What is the progression of the project flow if the condition of the Brain Up button being pressed is FALSE (released)?
A: If the condition is false, the project flow will continue to the [Stop motor] block before returning to the top of the stack repeating forever.

### Step 4: Adding the [Wait until] block.

Let's add the [Wait until] block:

• Add the [Wait until] block to your ArmUp project so that your project looks like the following:

• Save the project as ArmUp2. If students need help saving the project, refer to the Naming and Saving tutorial.

• Download the project to Slot 2 on the Clawbot, and then run it.

•
• Test to see if the arm will now spin up when the Brain Up button is pressed.

• Verify that when the Brain Up button is not pressed (released) that the Arm Motor stops.

• Write your observations of how the Clawbot behaved before and after adding the [Wait until] block to your project in your engineering notebook.

Teacher Toolbox - Stop and Discuss

After students have tested the project before and and after adding the wait until block, discuss with students how this allows the arm to continue spinning until the Brain Up button is released. Ask students to share their observations from their engineering notebooks. Facilitate a discussion by asking the following questions:

• Did you think that the project would work the first time before adding the wait until block?

• How did testing the first project allow you to recognize that there was something wrong with the it?

• Is the Brain Up button condition only checked once in the project?

Students' engineering notebooks can be maintained and scored individually (Google / .docx / .pdf) or as a team (Google / .docx / .pdf). The previous links provide a different rubric for each approach. Whenever a rubric is included in educational planning, it is good practice to explain the rubric or at least give copies to students before the activity begins.