<< Summary
Use the Adafruit TCS34725 with a Raspberry PI, in Java 
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.
Wiring
| TCS34725 | Raspberry PI | 3-color LED |
| 3V3 | 1. 3V3 VDC Power | |
| GND | 6. 0V (Ground) | Long pin (ground) |
| SDA | 3. SDA0 (I2C) | |
| SCL | 5. SCL0 (I2C) | |
| 11. GPIO 0 | red pin |
| 12. GPIO 1 | green pin |
| 13. GPIO 2 | blue pin |
|
|
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).
Running
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