TCS3200 Arduino Library
Comprehensive Arduino library for TCS3200 Color Sensor.
|
This page contains the comprehensive list of examples and usage of TCS3200 Arduino library.
To use the TCS3200 Arduino Library, include the "tcs3200.h" header file and create an instance of the TCS3200 class. Use the begin()
function to initialize the TCS3200 sensor, configure pins, and set default integration time and frequency scaling.
The TCS3200 sensor requires calibration for accurate color sensing. Calibration involves capturing readings for both the lightest and darkest colors to establish the range for color intensity mapping. Use the calibrate()
function to enable calibration mode, and after invoking calibrate_light()
and calibrate_dark()
functions to calibrate the sensor with white and black reference colors, respectively.
To obtain color intensity values for individual color channels (red, green, blue, and clear), use the following functions: read_red()
, read_green()
, read_blue()
, and read_clear()
. The read_rgb_color()
function returns the RGB color intensity values as an RGBColor structure.
The library provides control over the integration time and frequency scaling of the TCS3200 sensor. Integration time is set using the integration_time()
function, and frequency scaling is set using the frequency_scaling()
function. Integration time affects the accuracy and sensitivity of color measurements, while frequency scaling optimizes the trade-off between accuracy and response time.
White balancing is essential for achieving accurate color measurements. It allows users to calibrate the sensor based on a known white reference color. Use the white_balance()
function to set the white balance with an RGBColor structure, and white_balance()
to retrieve the current white balance settings.
The TCS3200 library supports color space conversions from RGB to other color spaces, including HSV, CMYK, and CIE 1931 XYZ. Use the corresponding functions (read_hsv()
, read_cmyk()
, and read_cie1931()
) to obtain color representations in the desired color space.
The library provides a template function nearest_color()
that allows users to find the nearest color label based on the current sensor readings. This is useful for applications like color classification and sorting.
The library allows users to define interrupt callbacks that trigger when the sensor readings exceed specified color thresholds. Use the upper_bound_interrupt()
and lower_bound_interrupt()
functions to set upper and lower color thresholds, respectively.
The TCS3200 library supports continuous color sensing and interrupt triggering in the loop. The loop()
function should be called in the main loop to trigger interrupt callbacks if defined.