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.
设定辨色仪灯 [on v]
Parameters |
Description |
|---|---|
state |
The state of the sensor’s light:
|
Example
当开始
[Continuously blink the light.]
永久循环
设定辨色仪灯 [on v]
等待 (2) 秒
设定辨色仪灯 [灭 v]
等待 (2) 秒
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%.
设定辨色仪灯功率为 (50)%
Parameters |
Description |
|---|---|
brightness |
The new brightness to set the sensor’s light to from 0% to 100%. |
Example
当开始
[Set the light to different power levels.]
设定辨色仪灯功率为 (25)%
等待 (2) 秒
设定辨色仪灯功率为 (50)%
等待 (2) 秒
设定辨色仪灯功率为 (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.
<辨色仪发现一个对象?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
当开始
[Stop driving after detecting an object.]
设定辨色仪灯 [on v]
驱动 [向前 v]
等待 (0.1) 秒
等到 <辨色仪发现一个对象?>
驱动停止
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.
<辨色仪测得 [红色 v]?>
Parameters |
Description |
|---|---|
color |
The color to detect:
|
Example
当开始
[Stop driving after detecting a green object.]
设定辨色仪灯 [on v]
驱动 [向前 v]
等待 (0.1) 秒
等到 <辨色仪测得 [绿色 v]?>
驱动停止
eye hue#
The eye hue block returns the hue detected by the Eye Sensor in degrees from 0 to 359.

(辨色仪色度值)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
当开始
[Display if an object is pink.]
永久循环
清除所有行
如果 <[290] [math_less_than v] (辨色仪色度值) [math_less_than v] [350]> 那么
打印 [Pink!] ▶
等待 (0.1) 秒
否则
打印 [Not pink!] ▶
等待 (0.1) 秒
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%.
<看到明亮对象?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
当开始
[Display whether a detected object is bright.]
设定辨色仪灯功率为 (100)%
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
等待 (0.1) 秒
如果 <看到明亮对象?> 那么
打印 [Bright object!] ▶
否则
打印 [Object not bright.] ▶
eye brightness#
The eye brightness block returns the brightness detected by the Eye Sensor from 0% to 100%.
(辨色仪亮度百分比)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
当开始
[Display whether a detected object is bright.]
设定辨色仪灯功率为 (100)%
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
等待 (0.1) 秒
如果 <(辨色仪亮度百分比) [math_less_than v] [70]> 那么
打印 [Object not bright.] ▶
否则
打印 [Bright object!] ▶