Play
Part 1 - Step by Step
- 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.
- 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 - ModelModel for students how to build the project in VEXcode GO and test their projects on the Field.
- Begin by showing students how to connect the Brain on their Code Base to their device in VEXcode GO. Because connection steps vary between devices, see the Connecting articles of the VEXcode GO VEX Library for specific steps to connect the VEX GO Brain to your computer or tablet.
- They will also need to configure VEXCode GO for the Code Base. If necessary, model the steps from the Configure a Code Base VEX Library article and ensure students can see the Drivetrain blocks in the Toolbox.
- Once the Code Base is configured, have students add the following [Comment] blocks to plan and organize their projects. The blocks under the “Collect Disk” [Comment] block will drive the Code Base to collect the Disk and return to the Mars Base. The blocks under the “Sort Disk” [Comment] block will have the Code Base use Eye Sensor data to deliver the Disk to the designated sorting area —based on the Disk color.
- Then, have students add the following blocks under the “Collect Disk” [Comment] block to have the Code Base drive to collect the Red Disk.
- 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.
- 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.
- 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.
- 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.
- 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.
- Have students name their project as Sort Red 1 and save it to their device. See the Open and Save section of the VEXcode GO VEX Library for device-specific steps to save a VEXcode GO project.
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.
- 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.
- 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?
- 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.
- 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?
- 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
- 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.
- 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 - ModelModel for students how to get started with their projects in VEXcode GO.
- If necessary, show students how to connect the Brain on their Code Base to their device in VEXcode GO. Because connection steps vary between devices, see the Connecting articles of the VEXcode GO VEX Library for specific steps to connect the VEX GO Brain to your computer or tablet.
- If necessary, model the steps from the Configure a Code Base VEX Library article and ensure students can see the Drivetrain blocks in the Toolbox.
- Have students name their project as Sort Red 2 and save it to their device. See the Open and Save section of the VEXcode GO VEX Library for device-specific steps to save a VEXcode GO project.
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.
- 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?
- 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.
There are many possible solutions for this challenge. The following is one example.
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.
- 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.
- 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?