The IQ Optical Sensor is one of the powerful IQ sensors which are designed for complete integration with the IQ robotics platform.
Description of the Sensor
The IQ Optical Sensor is a combination of the following sensors:
- Ambient light sensor: Reports the current amount of ambient light that the sensor is detecting. This could be the brightness levels a room, or the brightness of a particular object.
- Color sensor: Color information is available as RGB (Red, Green, Blue), hue and saturation, or grayscale. Color detection works best when the object is closer than 100 millimeters (mm).
- Proximity sensor: The proximity sensor measures reflected IR (infrared) energy sourced from an integrated IR LED. As such, the values will change with ambient light and object reflectivity.
The Optical Sensor also contains white LEDs.
These LEDs can be turned on and off, or set to a specific percentage of brightness.
This provides a consistent light source when detecting colors regardless of the surrounding light conditions.
The back of the sensor's housing has five holes to provide flexibility when mounting the sensor to a robot.
On the face of the sensor there is a small window where the Optical Sensors are located.
In order for the Optical Sensor to be functional with the IQ Brain, the sensor’s Smart Port and an IQ Brain’s Smart Port need to be connected with a Smart Cable.
The Optical Sensor will work with any of the 12 Smart Ports on the IQ Brain.
When connecting an IQ Smart Cable to the ports, be sure the cable’s connector is fully inserted into the port and the connector’s locking tab is fully engaged.
How the Optical Sensor Works
The IQ Optical Sensor receives light energy and converts the energy into electrical signals. The sensor's internal electronics (a hardware state machine) converts these signals into output signals to be received as an input by the IQ Brain.
As previously mentioned:
- The sensor’s color detection works best when the object is closer than 100 millimeters (mm) or approximately 3.9 inches.
- The proximity sensor measures reflected lR light intensity. This will cause the values to change with ambient light and object reflectivity.
The Optical Sensor needs to be paired with the VEXcode IQ to create a user program for the IQ Brain to utilize the sensor’s readings to control the robot’s behavior.
The IQ Brain in concert with a user program can be used with the Optical Sensor to:
- Turn the sensor’s white LED lights on or off.
- Set the white LED lights' percentage of power.
- Detect an object.
- Detect a color.
- Measure the percent brightness of ambient light.
- Measure the hue of a color in degrees.
Setup of the Optical Sensor
The placement of the Optical Sensor is very important to obtaining accurate readings.
Be sure no structure on the robot is in front of the small Optical Sensor window on the face of the sensor.
There needs to be a clear path in front of the sensor between any object being measured and the sensor.
Reading Optical Sensor Values
It is helpful to use the Devices screen on the IQ Brain to see the information the Optical Sensor is reporting.
- LED: the current brightness percentage of the LEDs. 0 is off, and 100% is fully on.
- BRT: the percentage of brightness of the ambient light in the room, or of an object
- PROX: the proximity of an object as near or far
- Hue: a hue value between 0 - 359 degrees. Each hue value has a color shade association.
To use the Sensor Dashboard, follow the steps in this article.
Adding the Optical Sensor as a Device in VEXcode IQ
Whenever a sensor is used with a programming language, it needs to be configured within that language.
With VEXcode IQ, this is accomplished by using the ‘Add a device’ feature from the Devices window.
To add the Optical Sensor to the configuration, follow the steps in this article.
Once the Optical Sensor has been added to your project, a new set of sensor blocks will become available.
For more information on the blocks from the ‘Sensing’ category pertaining to the Optical Sensor, view the Help information (Blocks project or C++ project).
Common Uses of the Optical Sensor
The Optical Sensor can produce several measurements which can be used to change the behavior of the robot. These features include:
Detect an object
This feature allows your robot to detect an object when it becomes within the range of the Optical Sensor.
The example project shown on the left is used to code a robot with an Optical Sensor mounted on the front to drive until it detects an object, such as a cube, and then stop driving once the object is detected by the Optical Sensor.
Detect a color
This feature allows your robot to identify the color of an object.
An example could be to code a robot with an Optical Sensor mounted on the front and a Touch LED attached to turn until it detects an object, such as a colored cube.
Once an object is detected, the robot stops turning for 5 seconds and glows the Touch LED the color of the object detected.
Measure ambient light
This feature allows your robot to measure the brightness of the light around it.
The example project shown on the left is used to drive a robot in a circle when the lights in a room are turned on, and stop the robot from driving when the lights are turned off.
Measure the hue value
This feature allows your robot to provide a number for the hue of color of an object.
The Optical Sensor reports the corresponding hue value in degrees from 0 to 359 based on the color wheel to the left.
This provides a more precise measurement of color as compared to a generalized red, green, or blue designation.
Uses of the Optical Sensor on a Competition Robot
The Optical Sensor will provide an excellent competitive advantage for competition robots. The ability to detect objects and their color will provide a great deal of information when designing autonomous routines. An object’s presence and hue of color will provide helpful information with the detection of game pieces and or goals.
For example, in the 2021 - 2022 VEX IQ Challenge, Pitching In, an Optical sensor could be angled to scan your robot's intake.
As soon as a ball is detected in the intake, this could automatically turn on the robot's arm to launch the ball.
No matter what the application the VEX IQ Optical Sensor is used for, there is no doubt it will be a welcomed addition for teams.
The function of the sensor’s values are open for the imagination of the user.