Coding the VEX 123 Eye Sensor with VEXcode 123

The 123 Robot contains many sensors, including an Eye Sensor. The Eye Sensor on the 123 Robot can be coded using VEXcode 123.

VEXcode 123 application workspace with a blank project.


The Eye Sensor on the 123 Robot

123 Robot shown from the front where the Eye Sensor is located. An arrow points to the Eye Sensor, which is located about halfway down the side of the robot and facing forwards.

The 123 Robot has an Eye Sensor on the front that can detect if there is an object present, as well as detect color (red, green, or blue).


VEXcode 123 Blocks Used with the Eye Sensor

Detecting object presence blocks

Two VEXcode 123 blocks, the first reading Drive forward until object, and the second reading Eye found an object?

The [Drive until] and <Found object> blocks report if the Eye Sensor is close to an object or not.

<Detects color> block

VEXcode 123 Detects color block that reads Eye detects red? The color dropdown menu is opened to indicate that it can be used to change the color value.

The <Detects color> block reports if the Eye Sensor detects the specified color.

(Brightness of) block

VEXcode 123 Brightness of block that reads 'eye brightness in %'.

The (Brightness of) block reports the brightness level as a percentage. This can be used to distinguish between light and dark objects and environments.

(Hue of) block

VEXcode 123 Hue of block that reads 'eye hue in degrees'.

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

Color wheel demonstrating how the 360 degree circle correlates to a hue value. The color red is at a degree of 0, the color green is at a degree of 120, and the color blue is at a degree of 240.

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


Common Uses of the Eye Sensor

The Eye Sensor on the 123 Robot can be used in many ways. The 123 Robot can use the Eye Sensor to initiate a sequence of behaviors when it is in the correct place to do so. For example, the 123 Robot can drive forward until it detects that it is near an object, such as a wall or another 123 Robot, then turn around to not crash into it as shown in this animation.

The 123 Robot can make decisions depending on if the Eye Sensor detects a blue object. This is useful if you want the 123 Robot to drive up to a specifically colored object, detect the color of objects as they pass by the sensor, or perform a certain behavior once a color is detected. In the example shown in this animation, if the Eye Sensor detects a blue object, the 123 Robot will turn right. If the Eye Sensor does not detect a blue object, the 123 Robot will turn left.

The 123 Robot can make decisions depending on if the Eye Sensor detects a bright or dark object. In the example shown in this animation, if the Eye Sensor detects a bright object, the 123 Robot will turn right. If the Eye Sensor does not detect a bright object, the 123 Robot will turn left.

VEXcode 123 application, with arrows showing the Hue of block being dragged onto the Add To Monitor Console icon. This will open the Monitor Console and will display the sensor value in the menu's table.

The 123 Robot can also report the hue color value of different objects. The Monitor Console can be used to see the hue value changing in real time, when the (Hue of) block is selected and dragged to the Monitor Console icon in the Workspace.

For more information on variable and sensing values monitoring in VEXcode 123, view this article

Color wheel demonstrating how the 360 degree circle correlates to a hue value. An arrow points to green where the value of 112 would sit on the wheel, showing an example of how hue values can be compared.

The value can then be compared to the hue chart.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: