Working with Color Sensor V3

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.

Have you tried using the colorMatcher. This should fix the slight imbalances that the color sensor should give

Yes. I have a function that .addsColorMatch(kColor) to colorMatcher

Have you tried it with / without the LED?

Try a method that just prints out what the colorSensor sees and then add sys.outs to see how far your code gets. I.e. debug it

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”.

Yes

Anywhere from 1 inch to right up on it

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.

Very helpfull.

1 Like

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.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.