Teacher Toolbox - Code
In this portion of the investigation, students will create the project to accomplish the recycling task. Students will need to:
-
Create the project file
-
Outline the steps using comment blocks
-
Translate the comment blocks into VEXcode IQ
-
Prepare and run the project
Step 1: Preparing to Code
Remember, you can always look to the tutorials for more information about blocks, sequences, and troubleshooting. Use the Help section when you want to know about what a specific block does or how to use it.
Using Blocks with Specificity
To move a specific distance, use the [Drive for] block, and change the direction and distance travelled by adjusting the parameters in the block.
To turn either right or left in any degree increment, use the [Turn for] block. Again, you can adjust the parameters to suit your design needs.
Open a New Project
The Programmer should start a new project with the Autopilot (Drivetrain) template, name, and save it. Since we will be creating a path for a recycle robot, rename your project “Recycle Run.”
For reminders on how to get started see the tutorials or refer to the example programs for reference.
Teacher Tips
- This should be the same process that was followed in the previous Drive and Turning Labs. Ask a non-Programmer student to remind the class of some of these steps, to make sure that everyone is engaged and following along with the process (even if they are not physically pushing the buttons.)
- Remind students about the Help section and that it is always available during their process, should they need additional support. Students should be encouraged to troubleshoot for themselves along the way, before asking for a teacher’s support.
-
If this is the student’s first time using VEXcode IQ, they can reference the Tutorials at any time during this investigation. The Tutorials are located in the toolbar.
Step 2: Create a List of Steps Using the Comment Blocks
What Are Comments?
Comments are usually added to projects to explain what a programmer wanted parts of the project to do. So they are helpful when collaborating and troubleshooting.
In this case, we are going to use them to help us make a general list of the steps the robot needs to do to complete its task.
What is the First Thing the Robot is Going To Do?
In the project, use the [comment] blocks to create a basic sequence in your group. The Recorder or Programmer should list the first 10 steps in VEXcode IQ, with a comment block for each step. See the example here.
The text in the block does not have to be as specific as the blocks themselves, as this is just a guide to follow when you begin to create the actual coding sequence.
Teacher Toolbox - Notes
This could also be done using a Note on the project. With a note, you would just type the steps similar to how you would list them on paper. In this case, the notes and comments could be used interchangeably. We are choosing to use comment blocks here for two reasons: to gain extra practice with the nature of the VEXcode IQ block method, and because you can add each comment step into your actual code block sequence as you work.
Click on the links to the VEX Robotics Knowledge Base for more information on comments and notes.
Step 3: Create the Coding Sequence
Now, it’s time to translate those steps into a block sequence.
-
Your robot should begin the path facing forward, so drag and drop the [drive for] block and set the parameters to match the first step in your path.
-
Look for the next step, and drop the turn for block and set the parameters to match the next step in your path.
When you get into a room, add an indicator block (like [set Touch LED color] or [play sound]). Because the Autopilot cannot actually pick things up, the indicator represents the robot picking up the recycling before moving on. -
Keep dragging and dropping blocks and setting parameters until you have finished the path for your Recycle Robot.
Teacher Toolbox
-
Check Along the Way
As your students are working and experimenting, walk around to monitor progress. Remind and encourage students to check their work as they go to make sure they are including ALL the necessary steps and checkpoints along the way. Testing the code in smaller sections can help prevent frustrations at the end of the process, and keep troubleshooting to a minimum. -
Teamwork Moves the Process Along
While coding is often an individual enterprise, In this experience, each member of the team can be involved in the coding process. You may want to point out teamwork strategies to help each team work more collaboratively. For an optional collaboration rubric, click one of the following links (Google Doc/.docx/.pdf)For instance: “Call and Code” procedures enable more people to be involved. The recorder lists the directions, the builder adds the distances, the driver calls the block instructions to the programmer, and the programmer codes it into the project.
Teacher Tips
To review, the configuration for Autopilot’s motors and sensors are:
-
Port 1: Left Motor
-
Port 2: Distance Sensor
-
Port 3: Color Sensor
-
Port 4: Gyro Sensor
-
Port 5: Touch LED
-
Port 6: Right Motor
-
Port 8: Bumper Switch
-
Port 9: Bumper Switch
Step 4: Preparing to Run Your Project
Before you run the project, do you have each of these items ready? The Builder should check each of the following:
- Are all the motors and sensors plugged into the correct port?
- Are the smart cables fully inserted into all the motors and sensors?
- Is the Brain turned on?
- Is the battery charged?
For a review of downloading and running your project, see the tutorials.
Step 5: Test Run your project
Now it is time to test out your project! Make sure your Autopilot robot is set up with enough space to be able to run the complete program without falling or bumping into another robot or team.
- The Operator should now run the first part of the project on the Autopilot robot by making sure the project is highlighted and then pressing the Check button.
- How did your test run go? Did your robot drive the path you thought it would? Follow the troubleshooting chart, and continue to create and check sections of code until you have a completed path.
Teacher Tips
-
Disconnect USB
If the students are using a computer, remind them to disconnect the USB cable from Robot Brain before running the project. -
Create a Defined Space for Each Team
You may want to give each team a large piece of paper that they can lay out on the floor or a table top on which to run their Autopilot project. This will help ensure that each team has enough space to complete the run without falling or entering another team’s workspace. -
Assessment
The open ended nature of this movement challenge means that there could be multiple designs and code sequences that solve the problem. So, how can you evaluate different successful solutions? From a computer science perspective, efficiency is key. The code sequence using the fewest number of blocks would be the preferred solution.