Skip to main content

Lesson 1: Eye Sensor Blocks

<Eye Sensor near object> Block

The <Eye Sensor near object> block reports if the Eye Sensor is close enough to an object to detect a color (red, green, blue, none).

VEXcode VR Eye Sensor Near Object block that reads 'Front Eye is near object?'.

The <Eye Sensor near object> block is a Boolean reporter block that reports TRUE when the Eye Sensor is close to an object that has detectable colors, and reports FALSE if the Eye Sensor is not close to an object that has detectable colors.

The Front or Down Eye Sensor can be selected from the drop-down menu on the <Eye Sensor near object> block.

VEXcode VR Eye Sensor Near Object block that reads 'Front Eye is near object?'. The sensor dropdown menu is opened, allowing the user to change the sensor from Front Eye to Down Eye.

Using Switch Blocks 

This is the Switch <Eye sensor near object> block.

VEXcode VR switch block version of the Eye Sensor Near Object block, with Python code that reads 'front_eye.near_object()'.

You can change the sensor parameter from the Front Eye Sensor to the Down Eye Sensor by replacing the code "front_eye" with "down_eye." Note that the sensor name should be typed using lowercase letters. Simply type in the parameter or hit the enter key or tab key to select the parameter suggestion that appears. 

VEXcode VR switch block version of the Eye Sensor Near Object block, with Python code that reads 'front_eye.near_object()'. An auto-complete dropdown menu allows the user to change the sensor between 'front_eye' and 'down_eye'.

<Color sensing> Block

The <Color sensing> block reports if one of the Eye Sensors detects a specific color.

VEXcode VR Color Sensing block that reads 'Front Eye detects red?'.

Choose which Eye Sensor to use on the <Color sensing> block.

VEXcode VR Color Sensing block that reads 'Front Eye detects red?'. A dropdown menu is opened to set the selected sensor as Front Eye or Down Eye.

The <Color sensing> block is a Boolean reporter block and reports TRUE when the Eye Sensor detects the selected color. The <Color sensing> block reports FALSE when the Eye Sensor does not detect the selected color. Choose which color to detect on the <Color sensing> block.

VEXcode VR Color Sensing block that reads 'Front Eye detects red?'. A dropdown menu is opened to set the selected color as red, green, blue, or none.

Using Switch Blocks

This is the Switch <Color sensing> block. 

VEXcode VR switch block version of the Color Sensing block with Python code that reads 'front_eye.detect(RED)'.

You can change the color parameter by typing a different color inside the parentheses. Be sure to enter the color using all capital letters. Suggestions for the color parameter will appear as you modify the text. 

VEXcode VR switch block version of the Color Sensing block with Python code that reads 'front_eye.detect(RED)'. The user can change the color value between BLUE, GREEN, NONE, and RED by typing it out or using the auto-complete feature.

Like the <Eye sensor near object> block, you can change the sensor parameter from the Front Eye Sensor to the Down Eye Sensor by replacing "front_eye" with "down_eye." Be sure to enter the sensor name using lowercase letters. Using proper syntax is important, so be sure to include an underscore (_) between the two words in the sensor name. 

VEXcode VR switch block version of the Color Sensing block with Python code that reads 'down_eye.detect(RED)' to demonstrate how to change the selected sensor.

Select the Next button to continue with the rest of this Lesson.