The VEX IQ Color Sensor
Read about the Color Sensor
To learn more about the Distance Sensor, ask the Reader to organize how the group will read the VEX IQ Color Sensor article from the VEX Library. This article will cover how the Color Sensor works and how it can be used.
Program with the Color Sensor
Have the Programmer open VEXcode IQ and follow these steps:
-
Begin by opening the Testbed template example project from VEXcode IQ.
- For help opening the example project, view the Use Example Projects and Templates tutorial video.
-
Build the following project and save it (macOS, Windows, Chromebook, iPad) as Color Sensor:
Test the Color Sensor
Have the Tester connect the VEX IQ Brain to your computer and then follow these steps:
- Download the project to the IQ Robot Brain.
- Run the project to report and print if an object is near and if it is, what color that near object is.
- For help downloading and running a project, view the Download and Run a Project tutorial video.
- Based on your observations of how the sensor behaved on the Testbed and the information from the reading, answer the following questions and ask the Recorder to document them in your engineering notebook:
- Does the Color Sensor report how far an object is using a range of values? Or, can it only report whether an object is detected by using 1 (TRUE) or 0 (FALSE)?
- How many different colors can the Color Sensor report to the IQ Brain?
Teacher Toolbox - Answers
The following answers may vary:
-
A Color Sensor reports whether it detects a near object as a binary value (0-FALSE or 1-TRUE). A Distance Sensor can report how far an object is using a range of values.
-
If students count the colors listed in the Color detects block, then they are likely to answer that the Color Sensor reports 14 possible colors. However, the Color Sensor only actually reports the names of 12 of those 14 colors, which you learn when you refer to the Color of block. So the Color Sensor can detect 14 colors and then categorizes them into 12 color names that can be reported. Additionally, the Color Sensor can report the hue value in degrees. If you refer to the Hue of block, you will see that it can report values ranging from 0 to 360 degrees. Any of these answers is acceptable but technically when reporting color names, the Color Sensor can report 12 in total by using the Color of block.
Program the Color Sensor to Detect Brightness
Open VEXcode IQ and follow these steps:
-
Begin by opening the Testbed template example project from VEXcode IQ.
- For help opening the example project, view the Use Example Projects and Templates tutorial video.
-
Build the following project and save it (macOS, Windows, Chromebook, iPad) as Brightness:
Test the Color Sensor's Ability to Track a Line
Connect the VEX IQ Brain to your computer and then follow these steps:
- Download the project to the IQ Robot Brain.
- Find or create a dark/black line on an otherwise clear white/light surface.
- Position the Testbed so that you can move the Color Sensor back and forth across the line and to the lighter surface a few times.
- Run the project to report and print if the Color Sensor detects darkness (on the line) or brightness (off of the line).
- For help downloading and running a project, view the Download and Run a Project tutorial video.
- With the Brightness project running, face the Color Sensor downward at the line and surface and slowly move it back and forth.
- Watch the Brain's screen for printed reports.
- Based on your observations of how the sensor behaved and the information from the reading, answer the following questions and ask the Recorder to document them in your engineering notebook:
- In what scenario might you use a Color Sensor to detect and/or follow a line?
- In the example project above, when the Brain prints "Off the line," what does that mean in terms of the brightness that it is detecting?
Teacher Toolbox - Answers
The following answers may vary:
-
A Color Sensor can be used to detect or follow a line in a competition setting to use lines on the field as guidance. Detecting and following lines can also be important for manufacturing or stocking robots where lines are used to indicate stopping points (so that they do not collide with shelves or other surfaces) or to delineate routes around the warehouse (so that robots do not need to navigate for themselves between locations). Of course, there are many possible additional answers including the ability of self-driving cars to stay within lanes on roads.
-
In the Brightness project, the Testbed should have printed "Off the line" whenever the brightness detected was greater than 25%. The white or light-colored surface is not likely to have a brightness detected as being lower than 25% - only the black line should.
Teacher Toolbox - Troubleshooting
When working with the Color Sensor, there could be instances where it does not behave as it should. If this occurs, begin troubleshooting by trying the following steps:
-
First begin by checking that the Color Sensor's firmware is up-to-date. Read this article for more information on how to update firmware.
-
If the firmware is up to date, further look into the Device Info screen on the IQ Brain to check whether colors and distances are being detected or not. Even with nothing in front of the Color Sensor, it should display the Color ("NONE") and the Distance ("Far"). Test a solid-colored object to see if the Color and Distance readings change. You can change the mode from "3 Color" to "12 Color" or "Grey Scale" by pressing the Check button. Then test the solid-colored object again to see if you are getting readings in all three modes.
-
The Device Info screen can also be helpful before running a project with the Color Sensor in a new environment where light levels might be different. When lighting conditions change, the Color Sensor might report different readings. Use the Device Info screen to see its current values so that adjustments can be made to the project to accommodate the change in ambient light.
-
You can also use the article, “How to Troubleshoot VEX IQ Sensors.”
-
If the Device Info reports accurate values, the issue could be that the student miscopied the project.
-
To troubleshoot the project, check that the device is configured properly - meaning that they used the correct Testbed example project. For more information on how to configure the Color Sensor, read the "How to Configure VEX IQ Sensors - VEXcode IQ" article.
-
Ensure that the students copied and built the project correctly. You can use the print block in VEXcode IQ to display the current sensor values on the Brain as the project proceeds through to the error or to the end of the project.
-
-
If the Device Info does NOT report accurate values, then the issue could be hardware-related.
-
To troubleshoot the hardware, try checking the port connection with the Smart Cable using the article, “How to Connect VEX IQ Devices to Smart Ports.”
-
If the Color Sensor is connected properly and it is still not behaving as it should, there could be a physical issue with the Color Sensor. Test switching it out with another Color Sensor.
-