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?
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.
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?
Select Next > to explore an example project.