summaryrefslogtreecommitdiff
path: root/CODE/debug/prewk/tcs34725
diff options
context:
space:
mode:
authorrobosoccer <robosoccer@mendelcollege.nl>2025-03-20 12:06:06 +0100
committerrobosoccer <robosoccer@mendelcollege.nl>2025-03-20 12:06:06 +0100
commit7e9328765f41a6055a722285678bc6bc09963c07 (patch)
tree7e02d638585b455fcea38a8e88d5fc71c3fcd1ba /CODE/debug/prewk/tcs34725
parent2bcc96fb10a4a84a7e5537d1d3258a7f919b6917 (diff)
downloadrobotica-7e9328765f41a6055a722285678bc6bc09963c07.tar.gz
robotica-7e9328765f41a6055a722285678bc6bc09963c07.zip
update
Diffstat (limited to 'CODE/debug/prewk/tcs34725')
-rw-r--r--CODE/debug/prewk/tcs34725/tcs34725.ino45
1 files changed, 45 insertions, 0 deletions
diff --git a/CODE/debug/prewk/tcs34725/tcs34725.ino b/CODE/debug/prewk/tcs34725/tcs34725.ino
new file mode 100644
index 0000000..88d1467
--- /dev/null
+++ b/CODE/debug/prewk/tcs34725/tcs34725.ino
@@ -0,0 +1,45 @@
+#include <Wire.h>
+#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_614MS, TCS34725_GAIN_1X);
+
+void setup(void) {
+ Serial.begin(9600);
+
+ if (tcs.begin()) {
+ Serial.println("Found sensor");
+ } else {
+ Serial.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);
+
+ 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.println(" ");
+}