Skip to main content
Teacher Portal

Play

Part 1 - Step by Step

  1. InstructInstruct students that they are going to create a project where the Robot Arm will move a disk based on its color.

    The Robot Arm will wait until a disk is detected, check the color of the disk, and make a decision based on that color. If the disk matches the color in the project, the Robot Arm will then lift the disk, and move it to another part of the tile, drop the disk, and return back to the starting location. Watch the video below to see how the Robot Arm could move the disk successfully by first sensing the disk and then lifting it to move to another location based on its color.

    Video file
  2. ModelModel how to add the [If then] block and the [Forever] block to the project with students. Explain that for this example, the Robot Arm will look for green
    • Have students open their Lab 4 Part 2 project and rename it Lab 5 Part 1.

      The project name box in the center of the VEXcode GO Toolbar is highlighted with a red box, and reads Lab 5 Part 1.
      Name the Project
    • If there are any students who were not present for Lab 4 or cannot find their project, have them recreate the Lab 4 Part 2 solution from the Lab 5 Image Slideshow.

    Lab 4 Part 2 Solution project. The blocks in the project read When started, Wait until eye found an object, energize electromagnet to boost, wait 1 second, spin arm up for 90 degrees, spin base right for 90 degrees, spin arm down for 90 degrees, energize electromagnet to drop, and spin base left for 90 degrees.
    Lab 4 Part 2 Solution
    • Before beginning, ensure students have connected their device to their Code Robot Arm (2-Axis) and that the configuration of their project is set to the Robot Arm. If needed, review the steps to Configure a Robot Arm and Connect a VEX GO Brain, then model these steps for students to connect and configure their Robot Arm.

    Note: When you first connect your Robot Arm to your device, the Gyro built into the Brain may calibrate, causing the Robot Arm to move on its own for a moment. This is an expected behavior, do not touch the Robot Arm while it's calibrating.

    • Drag the [If then] block into the Workspace.

    The same project as above with an If then block from the Toolbox dragged in to the left of the project in the Workspace.
    Add an [If then] block to the workspace
    • An [If then] block can be added around existing blocks. Show students the shadow that appears while the block is being added. This shadow indicates where the block will added to the stack.

    The same project with the If then block shown being added below the Wait until block, so that the rest of the blocks are inside the C of the If then block.
    Adding [If then] to a project
    • Ask students what condition they want to check for (Eye sensor detects an object of a specific color). Drag the <Color sensing> block into the [If then] block.

    The same project with the parameter of the If then block set to Eye detects red. The blocks now read When started, Wait until eye found an object, If eye detects red, then energize electromagnet to boost, wait 1 second, spin arm up for 90 degrees, spin base right for 90 degrees, spin arm down for 90 degrees, energize electromagnet to drop, and spin base left for 90 degrees.
    <Color sensing> Block Added
    • Explain that the <Color sensing> block can be used to detect the colors of the disks: red, blue, and green. Select the ‘green’ drop-down option.

    The same project, with the color parameter dropdown of the Eye detects color block open and set to green.
    Select 'green'
    • Explain that [If then] blocks are conditional statements that instruct the robot to check a condition, and if the condition is true, then this block will run.

    The same project with the parameter of the If then block now set to eye detects green.
    Project with the [If then] Block
    • Ask students how many times the Robot Arm will check the <Color sensing> condition in this project flow. Is that how many times they want it to be checked? In order to check it repeatedly, they will need to add a [Forever] block. Drag a [Forever] block into the Workspace and place it around the existing stack of blocks.

    The same project with a Forever loop being added so that all of the blocks from the Wait until block on are within the C of the Forever loop.
    Add [Forever] Block
    • Instruct students to select any of the three colors available in the <Color sensing> block in their project. They should attach the same colored disk to the Electromagnet on the Robot Arm and start their project to see how the Robot Arm moves the disk. 
      • Note: The Lab 5 Part 1 solution will vary slightly depending on the color groups choose.

    The same project with a Forever loop added. The project now reads When started, Forever, Wait until Eye found an object, If eye detects green, then energize electromagnet to boost, wait 1 second, spin arm up for 90 degrees, spin base right for 90 degrees, spin arm down for 90 degrees, energize electromagnet to drop, and spin base left for 90 degrees.
    Lab 5 Part 1 Solution

     

  3. FacilitateFacilitate conversation as students begin to create their projects. Encourage them to test their projects as they create them.
    • Does your project work as intended? Why or why not?
    • How would you describe what the [Forever] block does in this project?
    • What do you think would happen if we put a different colored disk in front of the Robot Arm? Would the Robot Arm move the disk? Why do you think that?
    • If you wanted to the Robot Arm to have sort two colors, what other blocks would you need to add?
  4. RemindRemind groups to ask questions if they get confused. If they have any problems using the new blocks, have them follow these steps again.

    For groups that have finished their project, have them help those groups that may need more assistance.

  5. AskAsk students to describe classroom or home events as “If...Then…” sentences. For example:
    • If I know the answer, then I raise my hand.
    • If the bell rings, then it is time for lunch.
    • If I get all of my homework done, then I get an hour of screentime.

Mid-Play Break & Group Discussion

As soon as every group coded their Robot Arm to pick up a colored disk successfully, come together for a brief conversation.

  • What did your Robot Arm do?
    • Encourage the students to speak as specifically as possible about the robot behaviors. Instead of “It saw a red disk”, say “The Robot Arm’s Eye Sensor detected a red disk.”
  • How did the Robot Arm make decisions in our projects? What blocks did we use to instruct the Robot Arm to make a decision?
  • How many times will the Robot Arm check for a color? Why? What if we removed the [Forever] block?
  • Use the project flow image to help facilitate this conversation.

Project flow of the if then block within the forever loop. An outer arrow goes from the bottom of the forever loop back up to the top and reads Repeats forever. The If then block has a green arrow showing that if eye detects green, and the condition is true, the blocks inside the C run. If eye does not detect green, it is false, and the project moves to the bottom of the forever loop.
Project flow with [Forever] block

Part 2 - Step by Step

  1. InstructInstruct students that they are going to add to their project to make the Robot arm will move colored disks to different locations depending on their color. Watch the video below to see how the Robot Arm could move the three disks successfully by first sensing the disk and then lifting it to move to another location based on the color. In the animation, first a green disk is moved, then a red disk, and lastly, a blue disk is successfully delivered.
    Video file
  2. ModelModel for students the steps to add on to their project to instruct the Robot Arm to move disks to different locations based on color.

    A top down view of the Code Robot Arm 2 Axis with disks in the final positions. The green disk is at the green flag at 12 o'clock; the red disk is at the green flag at the 3 o'clock position; and the blue disk is at the green flag at the 6 o'clock position.
    Disk Locations
    • Have each group to launch VEXcode GO on their device and open their Lab 5 Part 1 project. The new project will build on this project.
    • Students will need to save their project with a new name at the beginning of the Lab. Have them select “Save As” or "Save to Your Device" (depending on which VEXcode GO version you are using) from the File Menu and save their project as Lab 5 Part 2. If multiple groups are working on the same device, have them add their group name to the project.

      The project name box in the center of the VEXcode GO Toolbar is highlighted with a red box, and reads Lab 5 Part 2.
      Name the Project
    • Before beginning, ensure students have connected their device to their Code Robot Arm (2-Axis) and that the Robot Arm is configured. If needed, review the steps to Configure a Robot Arm and Connect a VEX GO Brain, then model these steps for students to connect and configure their Robot Arm.
    • Right now, the Robot Arm has instructions for what to do when a Green Disk is detected. By duplicating the blocks, the instructions for other colors can quickly be created.
    • Model how to duplicate blocks by right-clicking or long pressing on the [If then] block.

    The Lab 5 Part 1 project with the context menu open on the If then block, and the Duplicate option highlighted in a red box.
    Context Menu
    • Duplicate the [If then] block two times and add them beneath the first [If then] block.

    The same project with the If then blocks, and those contained within them, duplicated two more times, so there are 3 sets of if then blocks altogether.
    Duplicate blocks
    • Explain to students that they need to change the <Color sensing> block inside of the newly added [If then] blocks to the additional disk colors. Change the second <Color sensing> block to ‘red.’

    A close up view of the second If then block in the project with the parameter set to Eye detects red. The color parameter drop down is open in the eye detects color block and red is selected.
    Change to 'red'
    • The blocks inside this [If then] block need to be changed to tell the Robot Arm where to place a Red Disk. Change the parameters of the [Spin for] blocks that control the Base Motor to spin 180 degrees in each direction.

    The if eye detects red section of the project with the distance parameters of the spin for blocks that move the base highlighted with red boxes and set to 180 degrees. This sections of the project now reads, if eye detects red, then energize electromagnet to boost, wait 1 second, spin arm up for 90 degrees, spin base right for 180 degrees, spin arm down for 90 degrees, energize electromagnet to drop, and spin base left for 180 degrees.
    Change Drop Off Location
    • Now that the Robot Arm knows where to move any Red Disks or Green Disks, instruct students to edit the final stack. In this stack, the Robot Arm will move any Blue Disks to their designated location.
    • Have students place a Disk on the Electromagnet and start the project and see how their Robot Arm moves. Remind them that they should start the project with a Disk attached to the Electromagnet. Review the steps in Starting a Project in VEXcode GO if necessary.
    • Have students test their projects multiple times with all of the colored disks to ensure that it is working as intended.
  3. FacilitateFacilitate conversations about conditional statements in the project flow, as students change parameters and test their projects. Use the solution provided in the Lab 5 Slideshow to check their projects as you circulate.
    The solution project is divided into three sections, for the three If then blocks. Is shows the same project from before, with the final if then block set to eye detects blue.  The eye detects blue section of the project reads if eye detects blue, then energize electromagnet to boost, wait 1 second, spin arm up for 90 degrees, spin base left for 90 degrees, spin arm down for 90 degrees, energize electromagnet to drop, and spin base right for 90 degrees.
    Lab 5 Part 2 Solution

    As you circulate the room checking on groups, ask them some of the following questions to spark a discussion.

    • How would you change the code if we wanted all three colors to end up at the same location?
    • Describe to me how the Robot Arm will move if the Eye Sensor detects the color red.
    • What would happen if one of my [If then] blocks was outside the [Forever] block? Would the Robot Arm work as intended? Why or why not?
    • What if I put an orange beam in front of the Eye Sensor? Would the Robot Arm move it? Explain why it won’t move in terms of the project flow.
  4. RemindRemind groups to place their duplicated [f then] stacks inside of the [Forever] block. This is one of the possible errors that can occur while students create their projects.

    Remind students that trying and failing is okay! There may be multiple versions before they create their final project. Embrace failure, it’s a part of the learning process.

  5. AskAsk students how the decisions the Robot Arm makes are similar to or different from the decisions they make each day.

    What jobs can they think of that use decision making?