I am trying to code the Color Sensor V3 by Rev Robotics in java. I am using the exact same code from this github except I changed my color values a bit. The issue is that the color sensor is not reading perfect values. For each color, I am getting around .5 with or without the modified code. It does change from color to color so the sensor is working.
private final Color kBlueTarget = ColorMatch.makeColor(0.142, 0.437, 0.421); private final Color kGreenTarget = ColorMatch.makeColor(0.177, 0.577, 0.253); private final Color kRedTarget = ColorMatch.makeColor(0.482, 0.369, 0.149); private final Color kYellowTarget = ColorMatch.makeColor(0.314, 0.552, 0.134);
What should these values be? I tried setting them to the color value that the sensor was reading without any modifications and this still doesn’t seem to help the sensor.
What’s the distance between the sensor to the color you’re reading? The sensor’s datasheet says that “Color data is best collected within 2cm of the target for
the strongest color differentiation”.
The color value itself is a bunch of numbers and strings combined. When I get the value of getColor().red, I typically get anywhere from .1 to .6 depending on the color.
I had to rewrite the code from the website into my program and with a bit of adjustments, I was able to get our color sensor working. I must’ve added or deleted something when I wrote my code the first time.