Coding the VEX 123 Eye Sensor with VEXcode 123

The VEX 123 Robot has an Eye Sensor located in the front that is used to detect if an object is near, and if so, determine the color of that object.

eye-sensor-callout.png

The 123 Robot can be coded using VEXcode .

VEXcode_123.jpeg

The following article will cover:

  • How the Eye Sensor is Used
    • The Eye Sensor can detect
    • The Eye Sensor can report
  • Eye Detect Color Example Project
  • Eye Detect Object Example Project
  • Eye Report Hue Example Project

How the Eye Sensor is Used

The Eye Sensor on the front of the 123 Robot is used to detect if an object is near, and if so, determine the color of that object. In this image, the green 123 Robot detects the other 123 Robot that it is blue.

Copy_of_eye-sensor-how-its-used.png

The Eye Sensor can detect:

A certain color

The Eye Sensor can detect the colors red, green, and blue using the <Detects color> block.

_Detects_color__block.png

If an object is present

The Eye Sensor can detect if an object is close to it or not by using the <Found object> block.

_Found_object__block.png

The 123 Robot can also be coded to drive until the Eye Sensor detects an object using the [Drive until] block.

_Drive_until__block.png

This block can be used to detect objects in front of the 123 Robot, such as obstacles, walls, and even other 123 Robots as shown in the animation below.

The Eye Sensor can report:

Brightness levels

The Eye Sensor can report the brightness level of an object using the (Brightness of) block.

_Brightness_of__block_-_Copy.png

This can be useful when distinguishing between light and dark objects, or determining the environment of the 123 Robot. For example, if the 123 Robot drove into a dark space, such as inside a cardboard box, the (Brightness of) block can be used in a project to make the 123 Robot stop driving once it senses a low brightness level, or ‘dark.’

A hue color value in degrees

The Eye Sensor can report a hue color value of an object using the (Hue of) block. This can be useful when determining the colors of different objects.

_Hue_of__block.png

The (Hue of) block reports a hue value between 0 - 359 degrees.

vex-rainbow-circle-graphic_2.jpg


Eye Detect Color Example Project

The code below will drive the 123 Robot forward until it detects a blue object, such as a blue 123 Robot.

Wait_until_blue_project.png

Once a blue object is detected, the 123 Robot will stop driving.


Eye Detect Object Example Project

The code below will drive the 123 Robot forward until it detects an object.

Drive_forward_until_object_example.png

Once an object is detected, such as a wall on the 123 Field, the 123 Robot will stop driving.


Eye Report Hue Example Projects

The code below will use the 123 Robot to report the hue color value of different objects.

Eye_Hue_project.png

The Print Console can be used to see the hue value changing in real time. This example reported the hue value of a green 123 Robot.

Eye_Report_Hue_console.jpeg

The value can then be compared to the hue chart.

green_robot_hue.png