Last active
June 7, 2019 15:36
-
-
Save ampulhetadosaber/ed3c1a685299f0104639ab8b34ef6cf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include "Adafruit_TCS34725.h" | |
/* Inicializa com os valores padrões(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); | |
void setup() | |
{ | |
Serial.begin(9600); | |
if (tcs.begin())//Se conseguirmos iniciar o sensor significa que ele está conectado | |
{ | |
Serial.println("Sensor encontrado"); | |
} | |
else//caso contrário ele nao está conectado | |
{ | |
Serial.println("Sensor não encontrado, cheque suas conecções."); | |
while (1); | |
} | |
} | |
void loop() | |
{ | |
uint16_t r, g, b, c; | |
tcs.getRawData(&r, &g, &b, &c);//Pega os valores "crus" do sensor referentes ao Vermelho(r), Verde(g), Azul(b) e da Claridade(c). | |
//Agora vamos printar Os valores referentes a cada cor. | |
Serial.print("Vermelho : "); Serial.print(r, DEC); Serial.print(" "); | |
Serial.print("Verde : "); Serial.print(g, DEC); Serial.print(" "); | |
Serial.print("Azul : "); Serial.print(b, DEC); Serial.print(" "); | |
Serial.print("Claridade: "); Serial.print(c, DEC); Serial.print(" "); | |
Serial.println(" "); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment