Eye#
Introduction#
The VEX VR 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:
eye near object? – Returns whether the Eye Sensor is near an object.
eye detects color? – Returns whether the Eye Sensor detects a specific color.
eye brightness – Return the brightness detected by the Eye Sensor.
when eye – Executes the attached stack of blocks when the Eye Sensor detects or loses an object.
eye near object?#
The eye near 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.
<[FrontEye v] is near object?>
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to detect objects with. |
Example
when started
[Stop driving after detecting an object.]
drive [forward v]
wait (0.1) seconds
wait until <[FrontEye v] is near 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.
<[FrontEye v] detects [red v]?>
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to detect colors with. |
color |
The color to detect:
|
Example
when started
[Stop driving after detecting a green object.]
drive [forward v]
wait (0.1) seconds
wait until <[FrontEye v] detects [green v]?>
stop driving
eye brightness#
The eye brightness block returns the brightness detected by the Eye Sensor from 0% to 100%.
([FrontEye v] brightness in %)
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to detect brightness from. |
Example
when started
[Display whether a detected object is bright.]
drive [forward v]
wait until <[FrontEye v] is near object?>
wait (0.1) seconds
if <([FrontEye v] brightness in %) [math_less_than v] [70]> then
print [Object not bright.] ▶
else
print [Bright object!] ▶
when eye#
The when eye block runs the attached stack of blocks when the selected Optical Sensor detects or loses an object.
when [FrontEye v] [detects v] an object :: hat events
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to use. |
state |
Which action to trigger the hat block:
|
Example
when [FrontEye v] [loses v] an object :: hat events
[Find an object when it is lost.]
turn [right v]
wait until <[FrontEye v] is near object?>
stop driving