Coding the VEX 123 Eye Sensor using the Coder

The Eye Sensor within the VEX 123 Robot allows the robot to detect both the presence of nearby objects and the color of that object. The sensor plays an important role in helping the robot make decisions based on what it “sees”—such as detecting a red marker, spotting an obstacle, or choosing which way to turn during an activity.

The sensor is located on the front of the robot.

A 123 Robot with a yellow glow highlighting the rectangular sensor window on the side of the device.

Tip: For the most accuracy when using the Eye Sensor, avoid shadows, glare, or overly dim lighting.


Detecting Colors

The Eye Sensor can read the hue of the reflected light and can compare it against preset hue ranges to identify basic colors like red, green, or blue.

A circular color wheel displaying a full spectrum of hues labeled with degree values around the perimeter, increasing in 30-degree increments from 0° at the top to 360°.

A hue is a number on the color wheel from 0–360 degrees that represents the type of color.

3 coder cards that are orange colored from top to bottom reading if red, if green, if blue.

When you use a Coder Card like if red, if green, or if blue, the robot checks whether the hue reported by the Eye Sensor falls within a certain range for that color:

  • Red: 340°–20°
  • Green: 80°–145°
  • Blue: 160°–250°

Note: If the hue falls outside of these ranges—even if it still looks like the intended color to the human eye—the project may not behave as expected.


Detecting Light

In addition to detecting color, the Eye Sensor can also tell how much light is reflected off a surface. This helps the robot figure out whether something in front of it is bright or dark. Bright surfaces, like white paper or light-colored objects, reflect more light. Dark surfaces, like black tape or areas in shadow, reflect less.

2 coder cards that are orange colored from top to bottom reading if bright, if dark.

For the if bright Coder Card to activate, the object in front of the sensor needs to reflect at least 70% of the light. If the reflection is lower than that, it’s considered dark, and will instead work with the if dark Coder Card.


Detecting Objects

The Eye Sensor can also detect when something is physically close to the front of the robot. This is different from detecting color or brightness. Instead of measuring the color or how much light is reflected, the sensor checks whether an object is close enough to be considered “in front” of the robot.

An object needs to be approximately 18 mm away from the sensor to be detected. Note that this value can be impacted by environmental factors like ambient lighting.

3 coder cards vertically stacked. The first is blue and reads drive until object The bottom two are orange and read if object and if no object.

This kind of detection is used in Coder Cards like:

  • drive until object – moves the robot forward until something is detected ahead.
  • if object – runs a stack of cards if there’s something nearby.
  • if no object – runs a stack only if nothing is in front of the sensor.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: