Get ready to start coding with the AI Vision Sensor! In this lesson, you'll code your VEX AIM Coding Robot to detect and pick up a barrel placed randomly on the field. You’ll learn how to use the sensor to help your robot turn toward objects and collect them. Then you’ll create a project where your robot finds, collects, and kicks the barrel—no matter where the barrel starts!
Watch the video below to learn about:
- What the AI Vision Sensor is
- What a macro block is
- How to use the Turn until object block to turn towards a barrel
- How to use the Get object block to collect a barrel
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 does the AI Vision Sensor make it possible to collect an object with precision no matter where it is on the field?
- What did you see in the video that supports your statements?
- What kinds of things will you need to keep in mind as you code your robot to solve problems using the AI Vision Sensor?
- What questions do you have about coding the robot to turn to and get objects using the AI Vision Sensor?
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 does the AI Vision Sensor make it possible to collect an object with precision no matter where it is on the field?
- What did you see in the video that supports your statements?
- What kinds of things will you need to keep in mind as you code your robot to solve problems using the AI Vision Sensor?
- What questions do you have about coding the robot to turn to and get objects using the AI Vision Sensor?
After students watch the video and before practicing, come together for a whole-class discussion. Use student answers to the questions provided as the basis for discussion.
Note students' answers on the board to facilitate their idea development throughout the conversation. You may want to create and display a separate running list of questions about coding with the AI Vision Sensor that you can refer to and revisit throughout the unit.
Guided Practice
Now that you have begun learning about coding the robot with the AI Vision Sensor, it is your turn to practice!
Step 1: Set up the field by placing one orange barrel and the robot on the field as shown below.

Step 2: Model the movements of the robot needed to complete the task using Drive mode.
- Your task is to turn to the barrel and kick it at a field wall. Use the Up button on the VEX One Stick Controller to control the robot using the AI Vision Sensor.
- Use this task card (Google / .docx / .pdf) to guide your practice.
- Pro Tip: Pay close attention to the actions the robot takes when you control it using the Up button.
Step 3: Code the robot to complete the task.
- Your task is to code the robot using the AI Vision Sensor in VEXcode AIM to turn to the barrel and kick it at a field wall.
- Use this task card (Google / .docx / .pdf) to guide your practice.
- Pro Tip: Change the direction parameter in your Turn until object block to make your project more efficient.
Step 4: Explore! Place the barrel and robot in different locations around the field and drive and code to collect and kick them.
- Return to step 2 and complete the driving task, but place the barrel somewhere else on the field.
- Reset the barrel and robot in the same locations that you just tested by driving. Then code the robot to collect and kick the barrel.
- Repeat the exploration at least one more time by placing the barrel and robot in different locations. Record your observations in your journal each time you drive or code.
Resources for Practice:
The articles linked here are available if you need additional support while completing the activity.
Now that you have begun learning about coding the robot with the AI Vision Sensor, it is your turn to practice!
Step 1: Set up the field by placing one orange barrel and the robot on the field as shown below.

Step 2: Model the movements of the robot needed to complete the task using Drive mode.
- Your task is to turn to the barrel and kick it at a field wall. Use the Up button on the VEX One Stick Controller to control the robot using the AI Vision Sensor.
- Use this task card (Google / .docx / .pdf) to guide your practice.
- Pro Tip: Pay close attention to the actions the robot takes when you control it using the Up button.
Step 3: Code the robot to complete the task.
- Your task is to code the robot using the AI Vision Sensor in VEXcode AIM to turn to the barrel and kick it at a field wall.
- Use this task card (Google / .docx / .pdf) to guide your practice.
- Pro Tip: Change the direction parameter in your Turn until object block to make your project more efficient.
Step 4: Explore! Place the barrel and robot in different locations around the field and drive and code to collect and kick them.
- Return to step 2 and complete the driving task, but place the barrel somewhere else on the field.
- Reset the barrel and robot in the same locations that you just tested by driving. Then code the robot to collect and kick the barrel.
- Repeat the exploration at least one more time by placing the barrel and robot in different locations. Record your observations in your journal each time you drive or code.
Resources for Practice:
The articles linked here are available if you need additional support while completing the activity.
Remind students of group work expectations before beginning Guided Practice.
As students move through this Guided Practice session, emphasize the comparison between using the Controller to complete the task using the Up button, and coding the robot to complete the task using the macro blocks taught in this lesson (Turn until object and Get object).
Distribute the Step 2 task card to each student (Google / .docx / .pdf). As students are completing this task card, circulate around the room and engage students in discussions to learn about their progress and understandings. Ask questions like:
- What movements does the robot complete when you use the Up button to collect the barrel?
- If you had to code those movements, how would you break them down into each robot behavior you notice?
- Based on what you saw in the video, is that how you will plan your project? Why or why not?
- What do you notice on the robot's screen when it drives to collect the barrel? Does this tell you anything about how the robot is perceiving its environment?
After students complete their physical models, they will check in to share their progress with you. Once students have demonstrated that they have met all success criteria, distribute the Step 3 task card (Google / .docx / .pdf). Students will then complete the same task with the same setup, but this time by coding in VEXcode AIM.
As students are coding the robot, circulate around the room and engage students in discussions to learn about their coding progress and understandings. Ask questions like:
- What do you notice about the movement of the robot when you code it versus when you drove? Are the movements the same?
- How does using the AI Vision Sensor help you to code the robot with precision?
- How do the movements you predicted the robot would need to make when driving compare to the movements of the robot when coded? Explain the similarities and differences you see.
- What do you think would happen if the robot and/or the barrel started in different locations on the field?
In Step 4, students will explore what happens when they repeat steps 2 and 3, placing the robot and barrel in different locations around the field. Facilitate this step by asking questions such as:
- How does the robot behave when either it or the barrel is in a different location? Does it still collect the barrel in the same way?
- Macro blocks combine multiple robot behaviors into one block. What do you think those behaviors are? What VEXcode blocks do you think would be needed to cause the robot to complete those behaviors, if there were no macro blocks?
FYI - Setting Velocity
If your robot turns too quickly, it might spin past the object before the AI Vision Sensor has time to detect it. The sensor needs a moment to detect the object and process what it is. Slowing down can give it the time it needs. When you are coding, there are two blocks that can help with this.
Use the VEXcode API Reference to learn more about the Set move velocity and the Set turn velocity blocks, and how to use them in your project.
Wrap-Up
Now that you have practiced, it is time to share what you learned. Answer the following questions in your journal to help you reflect on your learning and prepare for a whole-class discussion:
- How is the robot's behavior when driving to collect and kick the barrel similar to the robot's behavior when coding the robot to collect and kick the barrel? How is it different?
- What did you notice about coding the robot using the AI Vision Sensor and the Macro blocks that you think will help you in future challenges? How might you apply what you've learned to challenges from past lessons?
- How does using the AI Vision Sensor allow you to be precise when coding, no matter where the robot and barrel are positioned on the field?
Now that you have practiced, it is time to share what you learned. Answer the following questions in your journal to help you reflect on your learning and prepare for a whole-class discussion:
- How is the robot's behavior when driving to collect and kick the barrel similar to the robot's behavior when coding the robot to collect and kick the barrel? How is it different?
- What did you notice about coding the robot using the AI Vision Sensor and the Macro blocks that you think will help you in future challenges? How might you apply what you've learned to challenges from past lessons?
- How does using the AI Vision Sensor allow you to be precise when coding, no matter where the robot and barrel are positioned on the field?
Guide students to share their learning in a whole-class discussion. Help students reflect on their learning through practice to converge on shared understandings or learning targets.
Use the questions students answered in their journals as the starting point for the discussion. Ask follow up questions to guide student understanding:
- On precision:
- Think back to Unit 5 - what if you had been able to use the AI Vision Sensor to code your robot in that challenge? How would it have changed your project?
- Can you think of a scenario where using the AI Vision Sensor would not help with precision positioning? Why not?
- On the AI Vision Sensor:
- What surprised you about using the AI Vision Sensor in your driving or coding?
- What information do you have on how the sensor perceives its environment?
- Now that you have begun to code using the AI Vision Sensor, what are some new questions you have about it?
Return to the shared document you created at the beginning of the lesson that lists questions students have about the AI Vision Sensor, and update it with students' answers based on what they learned in this lesson. Note any new questions students have.
Select Next > to explore an example project.