Skip to main content
Teacher Portal

Play

Part 1 - Step by Step

  1. InstructInstruct students that they are going to build on what they learned in Lab 1 to have the Code Base collect and return a Martian rock sample (the Red Disk). But now, they will code their robot to use Eye Sensor data to sort a Disk, based on its color.
    • Show students the Field setup with the sorting area marked with the X.  Once the Code Base collects the Red Disk, it will need to drop it in the square with the X. 

    Top-down view of a GO field with a red disk in the top left and a black 'X' drawn with dry erase marker on the bottom of the field to the left.
    Field Setup
    • Students will build a project with you then test it on the Mars surface (the Field). The animation below shows how the Code Base will move when this project is started. The robot first drives forwards until it reaches the Red Disk and then powers its electromagnet to pick it up. Next, the robot turns around and drives back to its starting position, before turning 90 degrees to the left and driving forwards to reach the sorting area marked with an X. After reaching the X, the robot drops the Disk and then turns around and drives back to its starting position.
    Video file
  2. ModelModel for students how to build the project in VEXcode GO and test their projects on the Field.

    VEXcode GO Blocks program that begins with a When Started block that has two comment blocks below it. The first comment reads 'Collect Disk', and the second reads 'Sort Disk'.
    Plan project with [Comment] blocks
    • Then, have students add the following blocks under the “Collect Disk” [Comment] block to have the Code Base drive to collect the Red Disk.

    A continuation of the VEXcode GO blocks project, now with blocks added below the first comment block to collect the red disk. The project now reads When Started, to collect the disk drive forward for 400mm and then energize the magnet to boost. Next, turn right for 180 degrees and finally drive forward for 400mm. The second comment block at the end reads 'Sort Disk'.
    Collect Disk code
    • Next, add on to the project together to have the Code Base sort the Disk. Drag a [Turn for] block into the workspace and attach it below the “Sort Disk” [Comment] block. Change the parameter to 'left' to have the Code Base turn toward the sorting area.

    A continuation of the VEXcode GO blocks project, now with a Turn For block set to turn left for 90 degrees added after the second comment. The project now reads When Started, to collect the disk drive forward for 400mm and then energize the magnet to boost. Next, turn right for 180 degrees and drive forward for 400mm. To sort the disk, turn left for 90 degrees.
     Add [Turn for] and set to left
    • Add an [If then] block, and place a <Detects color> block in the hexagon. Leave the <Detects color> block set to red. This will have the Code Base use the Eye Sensor to detect the color of the Disk. If this Disk is red, the <Detects color> block will report true, and the blocks that are added to the inside of the ‘C’ block will run.

    A continuation of the VEXcode GO blocks project, now with an If Then block that reads 'if eye detects red' added after the last Turn For block. The project now reads When Started, to collect the disk drive forward for 400mm and then energize the magnet to boost. Next, turn right for 180 degrees and drive forward for 400mm. To sort the disk, turn left for 90 degrees followed by an empty If Then block that reads 'if eye detects red?'.
     Add [If then] with <Detects color>
    • Add a [Drive for] and an [Energize electromagnet] inside the [If then] block and set [Energize electromagnet] to 'drop.' This will have the Code Base drive to the sorting area and drop the Disk.

    A continuation of the VEXcode GO blocks project, now with a Drive For block and an Energize Electromagnet block added inside the If Then block. The project now reads When Started, to collect the disk drive forward for 400mm and then energize the magnet to boost. Next, turn right for 180 degrees and drive forward for 400mm. To sort the disk, turn left for 90 degrees and if eye detects red then drive forward for 100mm and energize the magnet to drop.
    Add [Drive for} and [Energize electromagnet] set to 'drop'
    • Add a [Drive for] block and set it to reverse. This will have the Code Base return to the Mars Base after it has dropped the Disk.

    A continuation of the VEXcode GO blocks project, now with a Drive For block reading 'drive reverse for 100mm' added inside of the If Then block. The project now reads When Started, to collect the disk drive forward for 400mm and then energize the magnet to boost. Next, turn right for 180 degrees and drive forward for 400mm. To sort the disk, turn left for 90 degrees and if eye detects red then drive forward for 100mm and energize the magnet to drop. Finally and still inside the If Then block, drive reverse for 100mm.
    Add [Drive for] and set to reverse
    • Finally, add a [Turn for] block, and set it to 'left' to have the Code Base return to the starting position —facing the Mars surface collecting area.

    A continuation of the VEXcode GO blocks project, now with a Turn For block reading 'turn left for 90 degrees' block added inside of the If Then block. The project now reads When Started, to collect the disk drive forward for 400mm and then energize the magnet to boost. Next, turn right for 180 degrees and drive forward for 400mm. To sort the disk, turn left for 90 degrees and if eye detects red then drive forward for 100mm and energize the magnet to drop. Finally, and still inside the If Then block, drive reverse for 100mm and turn left for 90 degrees.
    Add [Drive for] and set to reverse

    Model for students how to test their project on the Field.

    • First, show them how to place their robot at the starting point (the Mars Base) and the Red Disk on the Field as shown in the image below.  Use the gridlines on the Field to help with alignment. The Disk and the Electromagnet can both be lined up on intersecting gridlines of the Field, to make it easier for students to be set up for success when they test their projects.

    Top down view of a GO field with a red disk in the top left and a black 'X' drawn with dry erase marker on the bottom of the field to the left. The robot is placed to the left side of the 'X' and directly below the red disk, facing towards the disk.
    Setup to Test
    • Once the Code Base is in place, select 'Start' in VEXcode GO to test the project.  Watch as the Code Base drives to collect the Red Disk, return to base, then deliver it to the sorting area.

    VEXcode GO Toolbar with the Start button called out in a red box, in between the Brain and Step icons.
    Select 'Start' to test the project
    • Students will need to select the 'Stop' button in the VEXcode GO Toolbar to stop the project.
    • For students who finish early and need additional challenges, have them move the Red Disk to a different location. Can they adjust their code to have the Code Base collect the Disk and deliver it to the same sorting area?
       
  3. FacilitateFacilitate a conversation with students as they test their projects.
    • How does the Code Base know when to energize the Electromagnet?
    • What blocks are used to have the Code Base detect the color of the Disk?
    • What would happen if the Code Base did not detect red? 

    Focus on the concept, not the precision. The goal of this Lab is to focus on the concept of using the Electromagnet in a project. If students slightly misaligned their robot, or the Disk is not exactly in the right place when they drive toward it, let them know that it's ok to move the Disk slightly to make sure it gets picked up by the Electromagnet.

  4. RemindRemind students to check the parameters in the [Drive for] blocks to make sure the project has the correct distances needed to collect then sort the Disk.
    • They should also check that the parameters in the [Turn for] blocks are set to have the Code Base turn the correct way to return to the Mars Base and toward the sorting area.

    In order to encourage a growth mindset and help students embrace the trial and error that is a part of coding and learn from the mistakes along the way, ask questions such as:

    • What mistake have you make that has taught you something?
    • What part of the Lab is tricky, or is making you think hard?
       
  5. AskAsk students how the Perseverance Rover might use an Eye Sensor to collect information and study the different Martian rock and soil samples. What could the Perseverance Rover study with the Eye Sensor?

Mid-Play Break & Group Discussion

As soon as every group has tested their project to have the Code Base collect and deliver the Red Disk to the sorting area, come together for a brief conversation.

Check in on students' progress and talk about what the Code Base is doing in their projects.

  • How does the Eye Sensor work in our project? What block(s) control the Eye Sensor?
  • How did you make the Electromagnet work with the Eye Sensor in your project?
  • What if we change the location of the Disks? Will this project still work? Why or Why not? What parameters would you change?

Part 2 - Step by Step

  1. InstructInstruct students that they are going to apply what they learned in Play Part 1 to iterate on their projects to make the Code Base collect the Red Disk from a new location and drop it in a new sorting area. They will need to change parameters in their projects to have the Code Base collect and sort the Disk successfully.
    • Show students the new Field setup and provide them with the drive distances so that they can focus on the code for this project. The Code Base will need to drive 200 millimeters  (~8 inches) to collect the Disk, and 350 millimeters (mm) (~14 inches (in)) to the new sorting area.

    Top down view of a GO field with a red disk to the left of the field and a black 'X' drawn with dry erase marker in the bottom right corner.
    Play Part 2 Field Setup
    • The following animation shows one possible way that the Code Base can move to complete the challenge. The robot first drives forwards until it reaches the Red Disk and then powers its electromagnet to pick it up. Next, the robot turns around and drives back to its starting position, before turning 90 degrees to the left and driving forwards to reach the sorting area marked with an X. After reaching the X, the robot drops the Disk and then turns around and drives back to its starting position.
    Video file
  2. ModelModel for students how to get started with their projects in VEXcode GO.

    If necessary, model for students how to test their project on the Field.

    • Show them how to set up to test by placing the Code Base at the Mars Base.

    Top down view of a GO field with a red disk to the left of the field and a black 'X' drawn with dry erase marker in the bottom right corner. The robot is placed in the bottom left corner of the field, directly below the red disk and facing towards it.
    Set up to test
    • Once the Code Base is in place, select 'Start' in VEXcode GO to test the project. Then, observe the behaviors of the Code Base.
    • Students will need to select the 'Stop' button in the VEXcode GO Toolbar to stop the project after it completes the challenge.

    If students finish early, have them change the location of the sorting area. Have them move it one square closer to the Mars Base.

    • The approximate distance for this sorting area is 250 millimeters (mm) (~10 inches (in)). Can they code their robot to collect and deliver the Disk to the same sorting area?
       
  3. FacilitateFacilitate a conversation with students as they build and test their projects with questions such as:
    • How does the Code Base need to move to collect the Disk? Can you show me with your hands?
    • What do you have to change to have your Code Base collect the Disk from the new location?
    • What parameters do you have to change to have the Code Base drop the Disk at the new sorting area?

    Prepare students for the trial and error that is an intrinsic part of the experimentation that they will engage in with this challenge. You may want to use the problem-solving cycle graphic from the Background page as a visual aide to establish a structure for the problem-solving process with your students. See the Background for more information for strategies to help students troubleshoot their projects and come up with their own solutions. 

    A diagram of the Student Problem Solving Cycle. Arrows show that the cycle repeats. The cycle starts with 'Describe the problem', then 'Identify when and where the problem began', then 'Make and test edits', and finally 'Reflect' before repeating.
    Student Problem-solving Cycle

    There are many possible solutions for this challenge. The following is one example.

    An example VEXcode GO blocks project to complete Play Part 2. The project reads When Started, to collect the disk drive forward for 200mm and then energize the magnet to boost. Next, turn right for 180 degrees and drive forward for 200mm. To sort the disk, turn left for 90 degrees and if eye detects red then drive forward for 350mm and energize the magnet to drop. Finally, and still inside the If Then block, drive reverse for 350mm and turn left for 90 degrees.
     Play Part 2 Possible Solution

    Focus on the concept, not the precision. The goal of this Lab is to focus on the concept of using the Eye Sensor with the Electromagnet in a project. If students slightly misaligned their Code Base, or the Disk is not exactly in the right place when they drive toward it, let them know that it's ok to move the Disk slightly to make sure it gets picked up by the Electromagnet.

    If students need additional support to connect the behaviors of the Code Base with the block commands in their project, use the Project Stepping feature to help students go through their project one block at a time to see how each block is being executed in their project. For more information on how to use the Project Stepping feature, view the Stepping Through Blocks tutorial in VEXcode GO.

    Icon for the Stepping Through Blocks tutorial in VEXcode GO.
    Through Blocks tutorial in VEXcode GO
  4. RemindRemind students to check the order (or sequence) of the blocks, and the parameters each block is set to in their projects before they test on the Field.
    • Did the Code Base turn right instead of left? What can you change to have the robot turn in the correct direction? 
    • Was the Disk further away? How can you change the parameter in the [Drive for] block to find the right distance for the Code Base to travel?
    • Is the <Detects color> block set to Red (the color of the Disk)?

    Talk students through problem-solving each issue as you circle the classroom. This will be an iterative process, so remind students that scientists who code the Mars rovers also have to try multiple times to get the rover to move how they intended.

  5. AskAsk students to think about how their project has changed from Play Part 1 to Play Part 2.
    • How has your project changed from the start of the Lab until now?
    • What did you change in your project to make it work better?
    • What change did you make that made it less successful? How did you fix it?