REV Color/Range Sensor
A versatile device used in robotics. It combines two functionalities into a single compact package:
Color Sensing:
Measures the intensity of red, green, and blue light reflected from a surface.
Can be used to identify colors or differentiate between objects based on their color.
The detected color is expressed in RGBA, which stands for Red, Green, Blue, and Alpha. It's a color model used to represent colors digitally, particularly in computer graphics and web design. Let's break down each component:
Red, Green, Blue (RGB): This is the core of the color model. Each of these primary colors is represented by a value ranging from 0 to 255 (or 0 to 1 in some systems). By combining different values for red, green, and blue, you can create a vast spectrum of colors.
Alpha: This represents the opacity or transparency of the color. It also ranges from 0 to 255 (or 0 to 1), where 0 is completely transparent (invisible) and 255 is completely opaque (solid).
Range Sensing:
Employs infrared light to determine the distance to an object.
Provides proximity information for obstacle avoidance or object tracking.
Key Features:
Combined functionality: Offers both color and distance sensing capabilities in one sensor.
Compact size: Easy to integrate into robot designs.
I2C communication: Simple to connect and communicate with the sensor.
Wide applications: Useful for line following, color sorting, object detection, and more.
To interact with the sensor, you must use an I2C address. These addresses are 8-bit values ranging from 16 to 254 in decimal (10 to FE in hexadecimal) and must be even. By default, a Modern Robotics color sensor has an I2C address of 3C hexadecimal. This address is assumed by an op mode written with Blocks Programming unless otherwise specified.
If you change the address of a color sensor, you must inform the Blocks Programming environment of the new address. You can do this using the "Set i2cAddress7Bit" or "Set i2cAddres8Bit" block. If you use blocks that refer to "7Bit," only the high 7 of the 8 bits are used, and the numbers range from 8 to 7F in hexadecimal (8 to 127 in decimal). For example, if you have an 8-bit address of 22 hexadecimal (34 decimal), its 7-bit address would be half of these values: 11 hexadecimal (17 decimal).
Alpha
Returns the current alpha value from the sensor.
Key points:
Purpose: To get the alpha value of the sensor.
Return value: an integer value ranging from 0 to 255.
Usage: This value can be used for various purposes, such as:
Detecting the presence or absence of an object.
Differentiating between light and dark surfaces.
Measuring the intensity of a light source.
Estimating distance based on light reflection (in some cases).
For example, When the sensor is pointed at a bright white surface, the alpha value will be close to 255. When the sensor is pointed at a dark surface or there's no object in front of it, the alpha value will be closer to 0.
Argb
Returns the current alpha-RGB value from the sensor.
Key points:
Purpose: To get the alpha-RGB value of the sensor.
Return value: an ARGB object.
Usage: This value can be used to get the full color information from the sensor.
Blue
Returns the current blue component from the sensor.
Key points:
Purpose: To get the blue value of the sensor.
Return value: an integer value ranging from 0 to 255.
Gain
Returns the current gain components from the sensor. "gain" refers to the sensitivity or amplification factor of the sensor. It represents how much the sensor's output signal is increased relative to the input it's measuring.
Key points:
Purpose: To get the gain value of the sensor.
Return value: a positive float value indicating the amplification factor.
Green
Returns the current green component from the sensor.
Key points:
Purpose: To get the green value of the sensor.
Return value: an integer value ranging from 0 to 255.
I2cAddess7Bit
Returns the 7 bit I2C address of the sensor.
Key points:
Return value: an integer indicating the 7 bit I2C address. The value ranges from 8 to 127.
I2cAddess8Bit
Returns the 8 bit I2C address of the sensor.
Key points:
Return value: an integer indicating the 8 bit I2C address. The value ranges from 16 to 254.
LightDetected
Gets the amount of light detected from the named range sensor.
Key points:
Purpose: To get the amount of light detected.
Return value: A float value ranging from 0.0 to 1.0.
RawLightDetected
Gets a value of the sensor, which is proportional to the amount of raw light detected.
Key points:
Purpose: To get the amount of light detected in proportional to raw amounts.
Return value: A positive float value.
RawLightDetectedMax
Gets the maximum raw light value that can be returned by the sensor.
Key points:
Purpose: To get the maximum possible raw light detected.
Return value: A positive float value.
Red
Gets the current red component from the sensor.
Key points:
Purpose: To get the red value of the sensor.
Return value: an integer value ranging from 0 to 255.
set ColorSensor Gain to
Sets the gain for the sensor. "gain" refers to the sensitivity or amplification factor of the sensor. It represents how much the sensor's output signal is increased relative to the input it's measuring.
Key points:
Purpose: To set the gain value for the sensor to magnify the sensor’s output signal.
Parameter: Gain can be any positive float number.
set ColorSensor 12cAddess7Bit to
Sets the 7 bit I2C address to the sensor.
Key points:
Purpose. Change the default 7 bit I2C address to differentiate sensors. The address must be an even number from 8 to 127 included.
set ColorSensor 12cAddess8Bit to
Sets the 8 bit I2C address to the sensor.
Key points:
Purpose. Change the default 8 bit I2C address to differentiate sensors. The address must be an even number from 16 to 254 included.
getDistance
Gets the current distance from the named range sensor using the requested distance unit. Valid values are DistanceUnit.METER, DistanceUnit.CM, DistanceUnit.MM, DistanceUnit.INCH.
Key points:
DistanceUnit: You can specify the desired unit for the distance measurement (CM, INCH, METER, MM).
Return Value: The getDistance method returns a double value representing the measured distance.
getNormalizedColors
Gets the normalized alpha-RGB color object detected by the sensor.
Key points:
Return Value: A normalized color object with values ranging from 0 to 1.
Last updated