眼睛#
介绍#
VEX GO 眼部传感器可以探测物体并识别其颜色、亮度和色调。它还允许您调整探测范围和照明设置,以获得更准确的读数。
Below is a list of all blocks:
set eye light — Turn the Eye’s light on or off.
set eye range — Set the Eye’s detection range.
set eye power — Set the Eye’s light power level.
eye found object? — Checks if the Eye detects an object.
eye detects color? — Checks if the Eye detects a specific color.
eye brightness — Returns the brightness detected by the Eye.
eye hue — Returns the hue detected by the Eye.
设置眼神光#
设置眼光块可以打开或关闭眼传感器的灯。
设定辨色仪灯 [on v]
参数 |
描述 |
|---|---|
状态 |
传感器灯的状态:
|
例子
当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Turn the light on and off.]
永久循环
设定辨色仪灯 [on v]
等待 [2] 秒
设定辨色仪灯 [灭 v]
等待 [2] 秒
设置眼睛范围#
“设置眼睛范围”模块用于设置眼睛传感器的检测范围。默认范围为“远”。
设置辨色仪的视距为 [near v]
参数 |
描述 |
|---|---|
范围 |
The sensor’s detection range:
|
例子
当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Drive to an object with different ranges.]
设置辨色仪的视距为 [far v]
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
驱动 [反 v] [100] [毫米 v] ▶
等待 [1] 秒
[Closer detection range.]
设置辨色仪的视距为 [near v]
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
驱动停止
设置眼力#
设置眼部亮度 模块用于设置眼部传感器灯光的亮度。如果灯光处于关闭状态,且新的亮度不为 0%,则该模块会将灯光打开。
设定辨色仪灯功率为 [50]%
参数 |
描述 |
|---|---|
亮度 |
将传感器的光线的新亮度设置为从 0% 到 100%。 |
例子
当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Turn on the light at different brightnesses.]
设定辨色仪灯功率为 [25]%
等待 [2] 秒
设定辨色仪灯功率为 [50]%
等待 [2] 秒
设定辨色仪灯功率为 [100]%
眼睛发现物体了吗?#
眼睛找到物体? 块返回一个布尔值,指示眼睛传感器是否检测到范围内的物体。
True — The sensor has detected an object.
False — The sensor has not detected an object.
<辨色仪发现一个对象?>
参数 |
描述 |
|---|---|
该块没有参数。 |
例子
当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Drive forward until an object is detected.]
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
驱动停止
眼睛能察觉颜色吗?#
**眼睛检测颜色?**块返回一个布尔值,指示眼睛传感器是否检测到指定的颜色。
True — The sensor detects the specified color.
False — The sensor does not detect the specified color.
<辨色仪测得 [红色 v]?>
参数 |
描述 |
|---|---|
颜色 |
检测颜色:
|
例子
当开始 :: hat events
[Build Used: Super Code Base 2.0]
[Drive forward until a Green Disk is detected.]
驱动 [向前 v]
等待 [0.2] 秒
等到 <辨色仪测得 [绿色 v]?>
驱动停止
眼睛亮度#
眼睛亮度块返回眼睛传感器检测到的亮度,从 0% 到 100%。
(辨色仪亮度百分比)
参数 |
描述 |
|---|---|
该块没有参数。 |
例子
当开始 :: hat events
[Build Used: Super Code Base 2.0]
[Monitor the brightness until a Red Disk is detected.]
驱动 [向前 v]
重复直到 <辨色仪测得 [红色 v]?>
清除所有行
打印 (辨色仪亮度百分比) ▶
等待 [0.1] 秒
结束
驱动停止
眼睛色调#
眼睛色调块返回眼睛传感器检测到的色调(0 到 359 度)。

(辨色仪色度值)
参数 |
描述 |
|---|---|
该块没有参数。 |
例子
当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Display the hue of a pink GO piece.]
永久循环
清除所有行
如果 <[10] [math_less_than v] (辨色仪色度值) [math_less_than v] [40]> 那么
打印 [Pink!] ▶
否则
打印 [Not pink.] ▶