IDUINO for maker’s life User Manual For TCS 3200 Color Sensor (ME069) www.openplatform.
IDUINO for maker’s life Description: TCS3200 Color Sensor is a complete color detector, including a TAOS TCS3200 RGB sensor chip and 4 white LEDs. The TCS3200 can detect and measure a nearly limitless range of visible colors. Applications include test strip reading, sorting by color, ambient light sensing and calibration, and color matching, to name just a few. The TCS3200 has an array of photodetectors, each with either a red, green, or blue filter, or no filter (clear).
IDUINO for maker’s life Example: Wire connection as below: Vcc--------------5V GND--------------GND S0--------------D3 S1--------------D4 S2--------------D5 S3--------------D6 OUT--------------D2 *******Code Begin********* #include #include #include
IDUINO for maker’s life // Select the filter color// void TSC_FilterColor(int Level01, int Level02) { if(Level01 != 0) Level01 = HIGH; if(Level02 != 0) Level02 = HIGH; digitalWrite(S2, Level01); digitalWrite(S3, Level02); } void TSC_Count() { g_count ++ ; } void TSC_Callback() { switch(g_flag) { case 0: Serial.println("->WB Start"); TSC_WB(LOW, LOW); break; case 1: Serial.print("->Frequency R="); //lcd.setCursor(0,0); //lcd.print("Start"); Serial.
IDUINO for maker’s life Serial.println("->WB End"); g_array[2] = g_count; TSC_WB(HIGH, LOW); break; default: g_count = 0; break; } } void TSC_WB(int Level0, int Level1) //White Balance { g_count = 0; g_flag ++; TSC_FilterColor(Level0, Level1); Timer1.setPeriod(1000000); } void setup() { TSC_Init(); lcd.init(); delay(100); lcd.backlight(); Wire.begin(); delay(100); lcd.setCursor(14,0); lcd.print("Color"); lcd.setCursor(0,3); lcd.print("S0:2 S1:3 S2:4 S3:5 OUT:6 LED:-"); Serial.begin(9600); Timer1.
IDUINO for maker’s life //for(int i=0; i<3; i++) // Serial.println(int(g_array[i] * g_SF[i])); } void loop() { g_flag = 0; for(int i=0; i<3; i++) { Serial.println(int(g_array[i] * g_SF[i])); //lcd.setCursor(0,1); //lcd.print(int(g_array[i] * g_SF[i])); } lcd.setCursor(0,1); lcd.print(int(g_array[0] * g_SF[0])); lcd.setCursor(6,1); lcd.print(int(g_array[1] * g_SF[1])); lcd.setCursor(12,1); lcd.print(int(g_array[2] * g_SF[2])); delay(4000); Clean2004(); } void Clean2004() { lcd.setCursor(0,1); lcd.