In this lesson, you'll code your VEX AIM Coding Robot to once again react, but this time to AprilTag IDs! You’ll explore how the example project from the end of unit 7 was constructed so you can understand more about If blocks (also known as “if then”) and how to build decision making into your code.
Watch the video below to learn about:
- How to ask questions in a project with If blocks.
- How to collect data from AI Vision in a project.
Now that you have watched the video, capture your thoughts in your journal. Answer these questions to guide your thinking and help you prepare for a whole-class discussion:
- How can you make a series of questions in a coding project?
- After watching this explanation, what changes might you want to make to your solution to the unit 7 activity?
- What questions do you have about coding the robot to make a decision using AI Vision data?
Guided Practice
Now that you have begun learning about making decisions with code, it is your turn to practice!
Step 1: Set up your field. Place one AprilTag against the center of each wall and your robot in the center of the field. Use the image below as a guide. You can use any AprilTag ID.

Step 2: Plan your project to make the robot react differently depending on the AprilTag ID detected. Together with your group, choose how you want your robot to react to each of the IDs on your field. Document your plan in your journal, and be specific.
- Use this task card (Google / .docx / .pdf) to guide you as you complete the activity.
- Be creative—use custom images, emojis, LEDs, built-in sounds, or other actions to design your robot's reactions.
Step 3: Code your robot to complete the activity, making sure it reacts differently depending on the AprilTag ID detected. Continue to use your task card. Build the project shown below to get started.
- Pro-Tip: Look at what you have chosen to get data about with the Get data block . Make sure that parameter choice matches the questions that are being asked as a follow-up in the rest of your code.
Step 4: Explore! Try different AprilTag IDs in each location. Does your project still work as intended? Think about how you can further customize your reactions, then continue to iterate on your project to improve it.
Additional Resources
The following articles and resources may help you as you work through this challenge:
FYI - Organizing Code with Comments
Comments can be used to add explanations or notes within a VEXcode project. They do not affect how the project runs and are useful for clarifying logic, documenting a plan, or otherwise communicating with others who may read the code. While the blocks in the project tell you what the robot is doing, the comments in a project tell you why the robot is doing that behavior or set of behaviors.
Watch this video to learn:
- How to add a Comment block to your project.
- How to add a Note to your project.
See these resources for additional information:
Wrap-Up
Now that you have completed the activity, it is time to share how you applied what you learned about making decisions with code to this challenge. Answer the following questions in your journal to help you reflect on your learning and prepare for a whole-class discussion:
- Describe your project. Include what decisions were made in the project and the reactions you coded.
- How does this project compare to the one you coded for unit 7? What changed and why?
- What was the biggest challenge your group faced? How did you work together to solve it?
Select Next > to move to the next lesson.