Main Content

Optical Sensor

Read proximity, color, and brightness

Since R2021b

Add-On Required: This feature requires the Simulink Coder Support Package for VEX EDR V5 Robot Brain add-on.

  • Optical Sensor block

Libraries:
Simulink Coder Support Package for VEX EDR V5 Robot Brain / Sensors

Description

The Optical Sensor block reads data from the optical sensor that is connected to the VEX® V5 Brain. You can use this block in your Simulink model to measure color, brightness, and proximity to an object from optical sensor.

Ports

Output

expand all

This port sensor measures the amount of reflected Infrared energy from an obstacle. The value of Proximity ranges from 0-255 with higher values indicating closeness to sensor. The nominal range of sensor is 10cm.

Data Types: double

This port represents the Hue, Saturation, Brightness/Value scale (HSB/HSV). The value for Hue ranges from 0 to 360 with 0 corresponding to red color. The value 120 corresponds to green and value 240 corresponds to blue. The Saturation and Brightness value ranges from 0 to 1.

Dependencies

To enable this port select the HSB (Hue, Saturation, Brightness) parameter.

Data Types: double

This port represents the color of the object in Red,Blue,Blue (RGB) scale.

Dependencies

To enable this port select the RGB (Red, Green, Blue) parameter.

Data Types: double

Parameters

expand all

Select the smart port on the V5 robot to which the VEX V5 inertial sensor is connected. There are 21 smart ports on the V5 robot.

The value ranges from 0 to 100 and the LED brightness increases with increase in the value.

Specify the sample time in seconds to determine how often the block reads values from the sensor. When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.

Additional Outputs

Select this parameter to enable HSB port. For more information, see HSB.

Select this parameter to enable RGB port. For more information on the RGB port, see RGB.

Data Types: double

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2021b