560
edits
Betulpeker (talk | contribs) No edit summary |
Betulpeker (talk | contribs) No edit summary |
||
Line 52: | Line 52: | ||
File:piecess.jpg | File:piecess.jpg | ||
</gallery> | </gallery> | ||
'''+Processing 3 ''' | |||
<source style="border:none; height:650px; overflow:scroll;" lang="c" line start="55" highlight="4"> | <source style="border:none; height:650px; overflow:scroll;" lang="c" line start="55" highlight="4"> | ||
Line 137: | Line 139: | ||
'''+Arduino''' | |||
<source style="border:none; height:650px; overflow:scroll;" lang="c" line start="55" highlight="4"> | |||
#include <Wire.h> | |||
#include "Adafruit_TCS34725.h" | |||
#define buttonDataPin 5 | |||
/* 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_50MS, TCS34725_GAIN_1X); | |||
void setup(void) { | |||
Serial.begin(9600); | |||
pinMode(buttonDataPin, INPUT); | |||
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; | |||
bool buttonPressed; | |||
tcs.getRawData(&r, &g, &b, &c); | |||
colorTemp = tcs.calculateColorTemperature(r, g, b); | |||
lux = tcs.calculateLux(r, g, b); | |||
buttonPressed = digitalRead(buttonDataPin); | |||
//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(" "); | |||
Serial.print(r , DEC);Serial.print(" "); | |||
Serial.print(g , DEC);Serial.print(" "); | |||
Serial.print(b , DEC);Serial.print(" "); | |||
if(buttonPressed == true) { | |||
Serial.print (1);Serial.print (" "); | |||
} | |||
else { | |||
Serial.print (0);Serial.print (" "); | |||
} | |||
Serial.println(""); | |||
} | |||
</source> | |||
'''+Black Box''' | '''+Black Box''' |
edits