Waveshare Color Sensor

Hey guys. First post, so bear with me. Time is of the essence, as my team will be leaving for Seattle in just over a week for a robotics competition. We are running into some problems with the color sensor.

Scope:
The sensor must distinguish between: red, yellow, blue, and green "fish" (wood cutouts) to be able to correctly sort them.

Hardware:
We are using the Waveshare Color sensor found here. The relevant documents and User Guide are in the Wiki created by the company and the sample code is attached.

Problems:
I cannot seem to get the code to distinguish between colors. Rather, if it is recognizing the colors, I do not know what I am looking at because the outputs in the Serial Monitor are not outputting RGB values between 0 and 255 (they can be much larger). I have verified that the hookup is correct to the arduino. I would also like to have the code only require white balance once at the beginning as this robot must operate on its own. Also attached is the sample of what the serial monitor is reading with a red fish in front of the sensor.

Any help is greatly appreciated.

Color_Sensor.ino (3.81 KB)

Hi, welcome to the forum.

Sorry to disappoint you, but you should have bought a normal color sensor with a normal interface.
For example this one : RGB Color Sensor with IR filter and White LED - TCS34725 : ID 1334 : $7.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Do you know if that code is any good ? Is someone else using that code ?

This uses a different way to read the sensor, it might be worth to try it : TCS3200_Color_Sensor_(SKU_SEN0101)-DFRobot

There are also libraries on Github, but it can be very tiresome to randomly try code from the internet.
It is best to find someone that has a working project with the TCS3200.

This seems to be a working project : Arduino and Color Recognition Sensor TCS230 TCS3200
It uses yet another method, using "pulseIn()". Using "pulseIn()" is a good way to read the timing.

This code seems to do what I need it to and with some modification will give me what I need to accomplish the task at competition.

Thank you very much sir!