Ks0053 keyestudio Color Sensor: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
<br>
==Introduction==
==Introduction==
TCS3200 programmable color light-to-frequency converter applies to colorimeter measurement such as color printing, medical diagnosis, calibration of PC color monitor as well as process control and color coordination in oil paint, textile, cosmetics and printing material industries.
TCS3200 programmable color light-to-frequency converter applies to colorimeter measurement such as color printing, medical diagnosis, calibration of PC color monitor as well as process control and color coordination in oil paint, textile, cosmetics and printing material industries.<br>
 
TCS3200 is built on the principle of three primary colors. Concretely speaking, TCS3200 allows only one specific primary color to go through and blocks other primary colors if a specific color filter was chosen. <br>
TCS3200 is built on the principle of three primary colors. Concretely speaking, TCS3200 allows only one specific primary color to go through and blocks other primary colors if a specific color filter was chosen. For example, when red filter was chosen, only red light can pass through while blue and green lights will be blocked out, so that we can get the intensity of red light. The strength of blue and green lights can be got in the same way. Finally, By analyzing the light strength of these three color, we can recognize the color reflected onto TCS3200.
For example, when red filter was chosen, only red light can pass through while blue and green lights will be blocked out, so that we can get the intensity of red light. The strength of blue and green lights can be got in the same way. Finally, By analyzing the light strength of these three color, we can recognize the color reflected onto TCS3200.<br>
<br>[[File:531.png|500px|frameless|thumb]]<br>
<br>[[File:531.png|500px|frameless|thumb]]<br>


<br>
==Specification==
==Specification==
*Color Recognition Sensor Module  
* Color Recognition Sensor Module
*Condition: New  
* Condition: New
*Chip: TCS230  
* Chip: TCS230
*Input Voltage: DC 3 ~ 5V  
* Input voltage: DC 3 ~ 5V
*Output Frequency Voltage: 0 ~ 5V
* Output frequency voltage: 0 ~ 5V  
*Use high brightness white LEDs  
* Use high brightness white LEDs
*Can be connected directly to Microcontroller  
* Can be connected directly to Microcontroller
*Static detection of the measured object color  
* Static detection of the measured object color
*Best Detection Distance: 10mm  
* Best detection distance: 10mm  
*Color and more details are shown as pictures


'''PLS NOTE that '''due to lighting effects, difference in monitor's brightness/ contrast settings etc, there could be some slight differences in the color tone between the pictures and the actual item!
<br>
<span style=color:red> '''NOTE: '''Due to lighting effects, difference in monitor's brightness/ contrast settings etc, there could be some slight differences in the color tone between the pictures and the actual item! <br>


<br>
==Connection Diagram ==
==Connection Diagram ==
<br>[[File:Ks0053-1.png|700px|frameless|thumb]]<br>
<br>
There are in total 10 pins on this sensor. The following is the correct connection between this color sensor and Arduino UNO:<br>
<br>[[File:533.png|600px|frameless|thumb]]<br>


<br>[[File:532.png|500px|frameless|thumb]]<br>
<br>
 
There are in total 10 pins on this sensor and among them, these two pins, namely GND and LED, are directly connected to each other by Jumper Cap. The following is the correct connection between this color sensor and Arduino UNO:
 
<br>[[File:533.png|500px|frameless|thumb]]<br>
 


==Sample Code ==
==Sample Code ==
Line 34: Line 38:
#define S0 6 // Please notice the Pin's define
#define S0 6 // Please notice the Pin's define
#define S1 5
#define S1 5
#define S2 4
#define S2 4
#define S3 3
#define S3 3
#define OUT 2
#define OUT 2
#define OE 7
#define LED 8
int g_count = 0; // count the frequecy
int g_count = 0; // count the frequecy
int g_array[3]; // store the RGB value
int g_array[3]; // store the RGB value
Line 111: Line 115:
void setup()
void setup()
{
{
pinMode(OE,OUTPUT);
pinMode(LED,OUTPUT);
digitalWrite(OE,LOW);
digitalWrite(LED,LOW);
TSC_Init();
TSC_Init();
Serial.begin(9600);
Serial.begin(9600);
Line 125: Line 133:
Serial.println(g_SF[1]);
Serial.println(g_SF[1]);
Serial.println(g_SF[2]);
Serial.println(g_SF[2]);
}
}
void loop()
void loop()
Line 132: Line 141:
Serial.println(int(g_array[i] * g_SF[i]));
Serial.println(int(g_array[i] * g_SF[i]));
delay(4000);
delay(4000);
}</pre>
}
 
</pre>
 
 
<br>


==Resources ==
==Resources ==


'''Video:'''
* '''Video:'''<br>
http://video.keyestudio.com/ks0053/


http://www.keyestudio.com/wp/2016/05/ks0053-keyestudio-color-sensor-for-arduino/
* '''Library and Code:'''<br>
https://fs.keyestudio.com/KS0053
 
<br>


'''Datasheet:'''
==Buy from==


http://www.keyestudio.com/files/index/download/id/1463714130/
*[https://www.keyestudio.com/keyestudio-tcs3200-color-recognition-sensor-detector-module-for-arduino-p0354.html    '''Official Website''']


'''Library File:'''
*[https://www.aliexpress.com/store/product/FREE-SHIPPING-TCS230-TCS3200-Color-sensor-Color-recognition-module-for-arduino/1452162_2055138455.html?spm=2114.12010612.8148356.1.69a22462FhXG8C    '''Aliexpress Store''']


==Buy from==
'''Website:''' <br>
http://www.keyestudio.com/keyestudio-color-sensor-for-arduino.html
<br>
'''Amazon Store:''' <br>
https://www.amazon.com/Keyestudio-Recognizing-Sensor-Arduino-raspberry/dp/B0177VJ2WQ/ref=sr_1_1?ie=UTF8&qid=1480303838&sr=8-1&keywords=keyestudio+Color+Sensor+for+Arduino




[[Category: Sensor]]
[[Category: Sensor]]

Latest revision as of 10:38, 9 September 2021


Introduction

TCS3200 programmable color light-to-frequency converter applies to colorimeter measurement such as color printing, medical diagnosis, calibration of PC color monitor as well as process control and color coordination in oil paint, textile, cosmetics and printing material industries.
TCS3200 is built on the principle of three primary colors. Concretely speaking, TCS3200 allows only one specific primary color to go through and blocks other primary colors if a specific color filter was chosen.
For example, when red filter was chosen, only red light can pass through while blue and green lights will be blocked out, so that we can get the intensity of red light. The strength of blue and green lights can be got in the same way. Finally, By analyzing the light strength of these three color, we can recognize the color reflected onto TCS3200.

thumb


Specification

  • Color Recognition Sensor Module
  • Condition: New
  • Chip: TCS230
  • Input voltage: DC 3 ~ 5V
  • Output frequency voltage: 0 ~ 5V
  • Use high brightness white LEDs
  • Can be connected directly to Microcontroller
  • Static detection of the measured object color
  • Best detection distance: 10mm


NOTE: Due to lighting effects, difference in monitor's brightness/ contrast settings etc, there could be some slight differences in the color tone between the pictures and the actual item!


Connection Diagram


thumb

There are in total 10 pins on this sensor. The following is the correct connection between this color sensor and Arduino UNO:

thumb


Sample Code

#include <TimerOne.h>
#define S0 6 // Please notice the Pin's define
#define S1 5
#define S2 4
#define S3 3
#define OUT 2
#define OE 7
#define LED 8
int g_count = 0; // count the frequecy
int g_array[3]; // store the RGB value
int g_flag = 0; // filter of RGB queue
float g_SF[3]; // save the RGB Scale factor
// Init TSC230 and setting Frequency.
void TSC_Init()
{
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(OUT, INPUT);
digitalWrite(S0, LOW); // OUTPUT FREQUENCY SCALING 2%
digitalWrite(S1, HIGH);
}
// 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); //Filter without Red
break;
case 1:
Serial.print("->Frequency R=");


Serial.println(g_count);
g_array[0] = g_count;
TSC_WB(HIGH, HIGH); //Filter without Green
break;
case 2:
Serial.print("->Frequency G=");
Serial.println(g_count);
g_array[1] = g_count;
TSC_WB(LOW, HIGH); //Filter without Blue
break;
case 3:
Serial.print("->Frequency B=");
Serial.println(g_count);
Serial.println("->WB End");
g_array[2] = g_count;
TSC_WB(HIGH, LOW); //Clear(no filter)
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); // set 1s period
}
void setup()
{
pinMode(OE,OUTPUT);
pinMode(LED,OUTPUT);
digitalWrite(OE,LOW);
digitalWrite(LED,LOW);
TSC_Init();
Serial.begin(9600);
Timer1.initialize(); // defaulte is 1s
Timer1.attachInterrupt(TSC_Callback);
attachInterrupt(0, TSC_Count, RISING);
delay(4000);
for(int i=0; i<3; i++)
Serial.println(g_array[i]);
g_SF[0] = 255.0/ g_array[0]; //R Scale factor
g_SF[1] = 255.0/ g_array[1] ; //G Scale factor
g_SF[2] = 255.0/ g_array[2] ; //B Scale factor
Serial.println(g_SF[0]);
Serial.println(g_SF[1]);
Serial.println(g_SF[2]);

}
void loop()
{
g_flag = 0;
for(int i=0; i<3; i++)
Serial.println(int(g_array[i] * g_SF[i]));
delay(4000);
}



Resources

  • Video:

http://video.keyestudio.com/ks0053/

  • Library and Code:

https://fs.keyestudio.com/KS0053


Buy from