#include <Wire.h>
#include "Adafruit_TCS34725.h"
#define TCS34725_INTEGRATIONTIME_700MS 0x00
#define TCS34725_GAIN_1X 0x00
#define GAIN_MASK1 0x00FF
const int pinLDR = A0; // Pin analógico donde está conectado el LDR
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
void setup() {
Serial.begin(9600);
if (tcs.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
// while (1);
}
Serial.println("Sistema de identificacion iniciado");
}
void loop() {
uint16_t r, g, b, c, colorTemp, lux;
// Leer valor del LDR
int valorLDR = analogRead(pinLDR);
// Leer valores del TCS34725
tcs.getRawData(&r, &g, &b, &c);
r = r & GAIN_MASK1;
g = g & GAIN_MASK1;
b = b & GAIN_MASK1;
c = c & GAIN_MASK1;
colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
lux = tcs.calculateLux(r, g, b);
Serial.print("Color Temp: ");
Serial.print(colorTemp, DEC);
Serial.print(" K - ");
Serial.print("Lux: ");
Serial.print(lux, DEC);
Serial.print(" - ");
Serial.print("R: ");
Serial.print(r, DEC);
Serial.print(" ");
Serial.print("G: ");
Serial.print(g, DEC);
Serial.print(" ");
Serial.print("B: ");
Serial.print(b, DEC);
Serial.print(" ");
Serial.print("C: ");
Serial.print(c, DEC);
Serial.print(" ");
Serial.print("LDR: ");
Serial.print(valorLDR);
Serial.println(" ");
delay(1000);
}