I2C Color Sensor

Hello,

So, I’ve a project which need a color sensor, but when I do what is on this site http://wiki.seeedstudio.com/Grove-I2C_Color_Sensor/ the colours’ informations are bad.
I’ve put the library correctly, so i don’t understand what’s the problem.

For more informations, I use this program:

#include <Wire.h>
#include <GroveColorSensor.h>
#include <ChainableLED.h>

#define CLK_PIN 7
#define DATA_PIN 8
#define NUM_LEDS 1 //The number of Chainable RGB LED

ChainableLED leds(CLK_PIN, DATA_PIN, NUM_LEDS);

void setup()
{
Serial.begin(9600);
Wire.begin();
}

void loop()
{
int red, green, blue;
GroveColorSensor colorSensor;
colorSensor.ledStatus = 1; // When turn on the color sensor LED, ledStatus = 1; When turn off the color sensor LED, ledStatus = 0.
while(1)
{
colorSensor.readRGB(&red, &green, &blue); //Read RGB values to variables.
delay(300);
Serial.print(“The RGB value are: RGB( “);
Serial.print(red,DEC);
Serial.print(”, “);
Serial.print(green,DEC);
Serial.print(”, “);
Serial.print(blue,DEC);
Serial.println(” )”);
colorSensor.clearInterrupt();
for(int i = 0; i<NUM_LEDS; i++)
{
leds.setColorRGB(i, red, green, blue);
}
}
}

the colours' informations are bad.

Give them a stern talking-to.

Please remember to use code tags when posting code

Sorry I did not understand the first sentence

Ok for the secondly point.

But, you don’t help me.

Do you want me to rewrite the program?

I don't know - do you think it needs rewriting?

You forgot to give a detailed explanation on why you believe "the colours' informations are bad", or what that even really means in your context.

The colours' informations are bad because when I change color, the values do not changes and there are negative values, which is impossible.

Roluminox:
The colours' informations are bad because when I change color, the values do not changes and there are negative values, which is impossible.

You store the return values in integers, which are signed. So, they can have negative values.

Paul

So to fix that: make red, green and blue an unsigned int type.

Ok thank you, but there is a problem because when I change color, the sensor does not see a difference.