TCS34725 color sensor code

Im green at programming~!~ Using and Arduino Uno and Adafruit TCS34725

This is the code I am using for the color sensor, I CANNOT get the LED to come on or change colors. When I monitor the serial monitor I do get data, but what I am seeing is C: R: G: B: and a code at end.

What I would like to see is what is shown online with

Color Temp: Lux: R: G: B: C:

as shown on page

I do see something in the library reference for a string like this Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);

But I need the correct code for a string like this uint16_t Adafruit_TCS34725::calculateColorTemperature(uint16_t r, uint16_t g, uint16_t b)

Calculates the color temperature from the Red, Green and Blue components.

I have checked all wiring etc and everything is wired correctly.

thanks very much in advance for your help.


#include <Wire.h>
#include “Adafruit_TCS34725.h”

// Pick analog outputs, for the UNO these three work well
// use ~560 ohm resistor between Red & Blue, ~1K for green (its brighter)
#define redpin 3
#define greenpin 5
#define bluepin 6
// for a common anode LED, connect the common pin to +5V
// for common cathode, connect the common to ground

// set to false if using a common cathode LED
#define commonAnode true

// our RGB → eye-recognized gamma color
byte gammatable[256];

Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);

void setup() {
Serial.println(“Color View Test!”);

if (tcs.begin()) {
Serial.println(“Found sensor”);
} else {
Serial.println(“No TCS34725 found … check your connections”);
while (1); // halt!

// use these three pins to drive an LED
pinMode(redpin, OUTPUT);
pinMode(greenpin, OUTPUT);
pinMode(bluepin, OUTPUT);

// thanks PhilB for this gamma table!
// it helps convert RGB colors to what humans see
for (int i=0; i<256; i++) {
float x = i;
x /= 255;
x = pow(x, 2.5);
x *= 255;

if (commonAnode) {
gammatable = 255 - x;

  • } else {*
    _ gammatable = x; _
    _ //Serial.println(gammatable*);
    void loop() {_

    uint16_t clear, red, green, blue;
    _ tcs.setInterrupt(false); // turn on LED*
    * delay(60); // takes 50ms to read*_

* tcs.getRawData(&red, &green, &blue, &clear);*
* tcs.setInterrupt(true); // turn off LED*

* Serial.print(“C:\t”); Serial.print(clear);*
* Serial.print("\tR:\t"); Serial.print(red);*
* Serial.print("\tG:\t"); Serial.print(green);*
* Serial.print("\tB:\t"); Serial.print(blue);*
* // Figure out some basic hex code for visualization*
* uint32_t sum = clear;
_ float r, g, b;
r = red; r /= sum;
g = green; g /= sum;
b = blue; b /= sum;
r = 256; g = 256; b = 256;

Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX);

* Serial.println();
//Serial.print((int)r ); Serial.print(" “); Serial.print((int)g);Serial.print(” "); Serial.println((int)b );
analogWrite(redpin, gammatable[(int)r]);
analogWrite(greenpin, gammatable[(int)g]);
analogWrite(bluepin, gammatable[(int)b]);