WHADDA WPSE325 Colour Sensor TCS3200 Module User Manual
- June 10, 2024
- WHADDA
Table of Contents
- WPSE325 Colour Sensor TCS3200 Module
- Introduction
- Safety Instructions
- General Guidelines
- What is Arduino®
- Product Overview
- Specifications
- Features
- Pin Layout
- Example
- include <TimerOne.h>
- include <Wire.h>
- include <LiquidCrystal_I2C.h> //This is only needed if You connect a I2C LCD
- define S0 6
- define S1 5
- define S2 4
- define S3 3
- define OUT 2
- define LED 7
- References
- Read User Manual Online (PDF format)
- Download This Manual (PDF format)
WPSE325 Colour Sensor TCS3200 Module
Introduction
To all residents of the European Union Important environmental information
about this product.
This symbol on the device or the package indicates that disposal of the device
after its lifecycle could harm the environment. Do not dispose of the unit (or
batteries) as unsorted municipal waste; it should be taken to a specialized
company for recycling. This device should be returned to your distributor or
to a local recycling service. Respect the local environmental rules. If in
doubt, contact your local waste disposal authorities.
Thank you for choosing Whadda! Please read the manual thoroughly before
bringing this device into service. If the device was damaged in transit, do
not install or use it and contact your dealer.
Safety Instructions
Read and understand this manual and all safety signs before using this
appliance.
For indoor use only.
- This device can be used by children aged from 8 years and above, and persons with reduced physical, sensory or mental capabilities or lack of experience and knowledge if they have been given supervision or instruction concerning the use of the device in a safe way and understand the hazards involved. Children shall not play with the device. Cleaning and user maintenance shall not be made by children without supervision.
General Guidelines
- Refer to the Velleman® Service and Quality Warranty on the last pages of this manual.
- All modifications of the device are forbidden for safety reasons. Damage caused by user modifications to the device is not covered by the warranty.
- Only use the device for its intended purpose. Using the device in an unauthorized way will void the warranty.
- Damage caused by disregard of certain guidelines in this manual is not covered by the warranty and the dealer will not accept responsibility for any ensuing defects or problems.
- Nor Velleman Group nv nor its dealers can be held responsible for any damage (extraordinary, incidental or indirect) of any nature (financial, physical…) arising from the possession, use or failure of this product.
- Keep this manual for future reference.
What is Arduino®
Arduino® is an open-source prototyping platform based on easy-to-use hardware and software. Arduino® boards are able to read inputs light-on sensor, a finger on a button or a Twitter message and turn it into an output activating of a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so, you use the Arduino programming language (based on Wiring) and the Arduino® software IDE (based on Processing). Additional shields/modules/components are required for reading a twitter message or publishing online. Surf to www.arduino.cc for more information.
Product Overview
The TCS3200 senses colour light with the help of an 8 x 8 array of photodiodes. Then using a Current-to-Frequency Converter the readings from the photodiodes are converted into a square wave with a frequency directly proportional to the light intensity. Finally, using the Arduino® Board we can read the square wave output and get the results for the colour.
Specifications
- supply voltage: 2.7-5.5 VDC
- dimensions: 28.4 x 28.4 mm
Features
- high-resolution conversion of light intensity to frequency
- programmable color and full-scale output frequency
- communicates directly with a microcontroller
- single-supply operation (2.7 V to 5.5 V)
- power-down feature
- non-linearity error typically 0.2 % at 50 kHz
- stable 200 ppm/°C temperature coefficient
Pin Layout
GND | ground |
---|---|
OUT | output frequency |
S0 | output frequency scaling selection input |
S1 | output frequency scaling selection input |
S2 | photodiode type selection input |
S3 | photodiode type selection input |
V | 5 VDC power supply |
G | ground |
OE | output enable, must be connected to G (ground) |
LED | LED enable input, low=ON |
Example
Connection
Arduino®
5 V
GND
D3
D4
D5
D6
D2
D7
GND
WPSE325
V
GND
S0
S1
S2
S3
OUT
LED
OE
- Connect your WPSE325 to your microcontroller (WPB100) as above.
- Download the library and data sheet from our website.
- Open the Arduino® IDE and import the three libraries. LiquidCrystal_I2C.h is only needed if you are also connecting an I²C LCD to your controller.
- Load the VMA325_code sketch into the IDE, compile and upload.
- Start the serial monitor. You should see a result like this:
Please also read the data sheet of the TCS2300, which is included in the VMA325.zip available from our website.
// CODE BEGIN
include <TimerOne.h>
include <Wire.h>
include <LiquidCrystal_I2C.h> //This is only needed if You connect a I2C LCD
to Your microcontroller LiquidCrystal_I2C lcd(0x27,20,4);
define S0 6
define S1 5
define S2 4
define S3 3
define OUT 2
define LED 7
int g_count = 0; // count the frequency
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);
pinMode(LED, OUTPUT);
digitalWrite(S0, LOW);// OUTPUT FREQUENCY SCALING 2%
digitalWrite(S1, HIGH);
digitalWrite(LED,HIGH) ; // LOW = Switch ON the 4 LED’s , HIGH = switch off
the 4 LED’s
}
// 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.println(g_count);
g_array[0] = g_count;
TSC_WB(HIGH, HIGH);
break;
case 2:
Serial.print(“->Frequency G=”);
Serial.println(g_count);
g_array[1] = g_count;
TSC_WB(LOW, HIGH);
break;
case 3:
Serial.print(“->Frequency B=”);
Serial.println(g_count);
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.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]);
//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.print(” “);
lcd.setCursor(0,2);
lcd.print(” “);
}
// CODE END
Modifications and typographical errors reserved – ©
Velleman Group nv. WPSE325_v01 Velleman Group nv, Legen Heirweg 33 – 9890
Gavere.
References
Read User Manual Online (PDF format)
Read User Manual Online (PDF format) >>