Eye#
Introduction#
The VEX 123 Eye Sensor can detect objects and identify their color, brightness, and hue. It also allows you to adjust detection range and lighting settings for more accurate readings.
Below is a list of all available blocks:
set eye light – Turn the Eye Sensor’s light on or off.
set eye power – Set the Eye Sensor’s light power level.
eye found object? – Returns whether the Eye Sensor detects an object.
eye detects color? – Returns whether the Eye Sensor detects a specific color.
eye hue – Return the hue detected by the Eye Sensor.
eye bright object? – Returns a Boolean indicating if the detected object is bright.
eye brightness – Return the brightness detected by the Eye Sensor.
set eye light#
The set eye light block turns the Eye Sensor’s light on or off.
set eye light [on v]
Parameters |
Description |
|---|---|
state |
The state of the sensor’s light:
|
Example
when started
[Continuously blink the light.]
forever
set eye light [on v]
wait (2) seconds
set eye light [off v]
wait (2) seconds
set eye power#
The set eye power block sets the brightness of the Eye Sensor’s light. If the light is off, this block will turn it on if the new brightness is not 0%.
set eye light power to (50)%
Parameters |
Description |
|---|---|
brightness |
The new brightness to set the sensor’s light to from 0% to 100%. |
Example
when started
[Set the light to different power levels.]
set eye light power to (25)%
wait (2) seconds
set eye light power to (50)%
wait (2) seconds
set eye light power to (100)%
eye found object?#
The eye found object? block returns a Boolean indicating whether or not the Eye Sensor detects an object within range.
True – The sensor has detected an object.
False – The sensor has not detected an object.
<eye found an object?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Stop driving after detecting an object.]
set eye light [on v]
drive [forward v]
wait (0.1) seconds
wait until <eye found an object?>
stop driving
eye detects color?#
The eye detects color? block returns a Boolean indicating whether the Eye Sensor detects a specified color, based on the detected hue value.
True – The sensor detects the specified color.
False – The sensor does not detect the specified color.
<eye detects [red v]?>
Parameters |
Description |
|---|---|
color |
The color to detect:
|
Example
when started
[Stop driving after detecting a green object.]
set eye light [on v]
drive [forward v]
wait (0.1) seconds
wait until <eye detects [green v]?>
stop driving
eye hue#
The eye hue block returns the hue detected by the Eye Sensor in degrees from 0 to 359.

(eye hue in degrees)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Display if an object is pink.]
forever
clear all rows
if <[290] [math_less_than v] (eye hue in degrees) [math_less_than v] [350]> then
print [Pink!] ▶
wait (0.1) seconds
else
print [Not pink!] ▶
wait (0.1) seconds
eye bright object?#
The eye bright object? block returns a Boolean indicating whether or not a detected object has a brightness value greater than 70%.
True – The detected object has a brightness value over 70%.
False – The detected object has a brightness value less than or equal to 70%.
<eye bright object?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Display whether a detected object is bright.]
set eye light power to (100)%
drive [forward v]
wait until <eye found an object?>
wait (0.1) seconds
if <eye bright object?> then
print [Bright object!] ▶
else
print [Object not bright.] ▶
eye brightness#
The eye brightness block returns the brightness detected by the Eye Sensor from 0% to 100%.
(eye brightness in %)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Display whether a detected object is bright.]
set eye light power to (100)%
drive [forward v]
wait until <eye found an object?>
wait (0.1) seconds
if <(eye brightness in %) [math_less_than v] [70]> then
print [Object not bright.] ▶
else
print [Bright object!] ▶