🚚 Free delivery on orders over: €35 Croatia • €60 EU • $100 US

HUM: TCS230 COLOR RECOGNITION SENSOR

HUM: TCS230 COLOR RECOGNITION SENSOR-Uncategorized

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Dasduino and the basic code. Everything else is left to your imagination.

INTRODUCTION

This color sensor module contains the TCS230, a programmable converter which converts light to frequency. It can filter RGB from the light source, and convert it into rectangular waves with frequency directly proportional to the intensity of light. It is used in robotics for object recognition,”lines” tracking, in design for the chameleon effect and more.

Characteristics:
Voltage: 2.7 – 5.5V
Precision: 0.2% na 50kHz
Dimensions: 29x21mm

HOW DOES IT WORK?

TCS230 combines photodiodes and voltage-to-frequency converter. It contains an 8×8 series of photodiodes: 16 with blue, 16 with green, 16 with red filter and 16 without filter. If you take a magnifying glass and target the center of the chip, you will be able to see these filters. The sizes are 120x120um, and they serve to filter “random” radiation. On the module are 4 wide-angle 5mm cold white LED diodes in order to increase radiation and other passive components necessary for direct reading of the output pin.

Pinout

GND – gnd
OE – Output enable, active LOW
OUT – output frequency (fo)
S0, S1 – pins for output frequency scaling (0%, 2%, 20%, 100%)
S2, S3 – pins for RGB filters selection (red, blue, green, without)
Vcc – 2.7 – 5.5 VDC

For more, check the datasheet.

MODULE AND DASDUINO

According to the datasheet, we have pined the pins as in the picture above.

GND – gnd
OE – gnd, LOW activates OUT pin
OUT – PIN10 of the Dasduino, the only input pin, we can use any
S0, S1 – +5V, combination when both pins are HIGH scales the output pin to 100%. For greater accuracy, use lower [%]. In that case, with Arduino, it is necessary to use some Timer library. 
S2 – PIN7 of the Dasduino, we combine it with S3 in order to change filters according to the table below
S3 – PIN6 of the Dasduino, we combine it with S2 in order to change filters according to the table below
Vcc – +5V

S2/S3 combination for changing filters:

NOTE: the code below shows the module work principle, for more precise data, calibrations and exact measurements are needed and you can get them with the help of  TimerOne library.

///////////////////////////////////////////////////////////////////////////////
/*                                                                           */
/*                                                                           */
/* (c) e-radionica.com 2015 - http://e-radionica.com/hr/faq/#privatnost      */
/* techsupport@e-radionica.com                                               */
/*                                                                           */
/*                                                                           */
/* TCS230 - HUM tutorial                                                     */
///////////////////////////////////////////////////////////////////////////////
/*
  GND - GND, OE
  +5V - Vcc, S0, S1
  D10 - OUT
  D7  - S2
  D6  - S3
*/
const int s2 = 7;
const int s3 = 6;
const int out = 10;
byte crvena, zelena, plava;
void setup() {
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);
  pinMode(out, INPUT);
  Serial.begin(9600);
}
void loop() {
  ProvjeriBoje();
  Serial.print("Crvena = " + String(crvena) + "\t");
  Serial.print("Zelena = " + String(zelena) + "\t");
  Serial.print("Plava = " + String(plava) + "\n");
  delay(100);
}
void ProvjeriBoje() {
  // without red filter
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  crvena = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
  
  delay(10);
  // without blue filter
  digitalWrite(s2, LOW);
  digitalWrite(s3, HIGH);
  plava = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
  
  delay(10);
  // without green filter
  digitalWrite(s2, HIGH);
  digitalWrite(s3, HIGH);
  zelena = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
}