Eye#
Introduction#
The VEX VR Eye Sensor can detect objects and identify their color, and brightness.
Below is a list of all available blocks:
eye near object – Reports whether the Eye Sensor detects an object within range.
eye detects color – Reports whether the Eye Sensor detects a specified color.
eye brightness – Reports the brightness detected by the Eye Sensor.
when eye – Runs the attached stack of blocks when the Eye Sensor detects or loses an object.
eye near object#
The eye near object Boolean block reports whether the Eye Sensor detects an object within range.
True — The Eye Sensor detects an object.
False — The Eye Sensor does not detect 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 Boolean block reports whether the Eye Sensor detects a specified color.
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 reporter block reports how much light is reflected back to the Eye Sensor, as a percentage from 0% to 100%.
A higher percentage means more light is reflected back to the Eye Sensor. A lower percentage means less light is reflected back.
([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 hat block runs the attached stack of blocks when the selected Eye Sensor detects or loses an object.
when [FrontEye v] [detects v] an object :: hat events
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to use. |
state |
When the attached stack of blocks will run:
|
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