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);
}
}
}