<< Summary

Use the Adafruit TCS34725 with a Raspberry PI, in Java Raspberry PI
Color recognition

The board we are talking about here is this one.
We will also use a 3-color LED, like this one.

We assume you've enabled I2C on the Raspberry PI.

What this demo does

We want to use the TCS34725 to recognize a color. In the demo, we will put a CD sleeve on its sensor, and see what color it is.
To prove it, we will light up a 3-color LED, showing that the color has been identified.
Attention! Unlike the Arduino, the Raspberry PI cannot emit analog signals! We will turn the 3-color LED to red, blue, or green. Nothing else!
See it as if you were asking the Raspberry PI about the color you show to the TCS34725 a question like
"Is it more blue, more green, or more red?".
We will address that issue in another demo, using a Digital to Analog Converter (DAC), or Pulse Width Modulation (PWM), which is suitable for lights.


TCS34725Raspberry PI3-color LED
3V31. 3V3 VDC Power
GND6. 0V (Ground)Long pin (ground)
SDA3. SDA0 (I2C)
SCL5. SCL0 (I2C)
11. GPIO 0red pin
12. GPIO 1green pin
13. GPIO 2blue pin
Raspberry PI P1 Connector map
You might want to put some resistor between the 3-color led and the Raspberry PI, I'll let you come up with the right one (in other words, don't blame me if you blow out your led).


Launch the script located in the I2C.SPI directory, named tcs34725.main.

 Prompt> ./tcs34725.main
And here is what it could look like:

Oliv did it