#include #include #include "Adafruit_TCS34725.h" /* Example code for the Adafruit TCS34725 breakout library */ /* Connect SCL to analog 5 Connect SDA to analog 4 Connect VDD to 3.3V DC Connect GROUND to common ground */ /* Initialise with default values (int time = 2.4ms, gain = 1x) */ // Adafruit_TCS34725 tcs = Adafruit_TCS34725(); /* Initialise with specific int time and gain values */ Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X); SoftwareSerial softSerial(PA0,PA1); void setup(void) { softSerial.begin(115200); if (tcs.begin()) { softSerial.println("Found sensor"); } else { softSerial.println("No TCS34725 found ... check your connections"); while (1); } // Now we're ready to get readings! } void loop(void) { uint16_t r, g, b, c, colorTemp, lux; tcs.getRawData(&r, &g, &b, &c); // colorTemp = tcs.calculateColorTemperature(r, g, b); colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c); lux = tcs.calculateLux(r, g, b); softSerial.print(" Red: "); softSerial.println(r); softSerial.print("Green: "); softSerial.println(g); softSerial.print(" Blue: "); softSerial.println(b); softSerial.print("White: "); softSerial.println(c); }