Color 5 Click Board
Color 5 Click Board
The Color 5 Click Board™ is a colour sensing board, which utilises the P12347-01CT, an integrated colour sensing device. This sensor is able to sense the red (R), green (G), and blue (B) components of light, providing measurement via the I2C interface. Besides sensing R, G and B components, there is an IR sensor too, allowing this Click Board™ to sense the intensity of the infra-red spectrum. In addition, this sensor is equipped with 3 LEDs, one for each colour component of the white light: red, green and blue LEDs are embedded into the sensor itself. The combination of photo-sensing and photo-emission elements allows for yet another feature of this sensor - proximity sensing.
Software Support
We provide a library for the Color 5 Click Board™ on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Library Description
The library initializes and defines the I2C bus driver and drivers that offer a choice for writing data in the register. The library includes a function to read the color through a red, green, and blue filter and IR data. The user can set the color of the LEDs. The sensor has a proximity mode with which it can detect the object in front of the sensor. The user has a function for reading light through one filter as well as reading the light through all the filters.
Key Functions
void color5_setConfiguration(uint8_t reg, uint8_t _data)
- Functions for configuration sensor
void color5_setLedDriver(uint8_t red, uint8_t green, uint8_t blue)
- Functions for setting led color
uint16_t color5_readData(uint8_t reg)
- Functions for reading data from register
uint8_t color5_getInterrupt()
- Functions for proximity detect
Example Description
The application is composed of three sections :
- System Initialization - Initializes I2C module
- Application Initialization - Initializes driver init and configuration proximity and led driver
- Application Task - (code snippet) - Reads the color values through a red, blue, green filter and IR data. Checking that the proximity sensor detects the object.
void applicationTask() { // Color init color5_setConfiguration(_COLOR5_REG_RGB_SENSOR_CTRL,_COLOR5_CFG_SENSOR_RESET | _COLOR5_CFG_MANUAL_SETTINGS_MODE ); color5_setConfiguration(_COLOR5_REG_RGB_SENSOR_CTRL, _COLOR5_CFG_LOW_GAIN | _COLOR5_CFG_MANUAL_SETTINGS_MODE ); RED_Data = color5_readData( _COLOR5_REG_OUT_DATA_RED_MSB ); IntToStr( RED_Data, dataTxt ); mikrobus_logWrite( "RED data : ", _LOG_TEXT ); mikrobus_logWrite( dataTxt, _LOG_TEXT ); mikrobus_logWrite( " nm", _LOG_LINE ); GREEN_Data = color5_readData( _COLOR5_REG_OUT_DATA_GREEN_MSB ); IntToStr( GREEN_Data, dataTxt ); mikrobus_logWrite( "GREEN data : ", _LOG_TEXT ); mikrobus_logWrite( dataTxt, _LOG_TEXT ); mikrobus_logWrite( " nm", _LOG_LINE ); BLUE_Data = color5_readData( _COLOR5_REG_OUT_DATA_BLUE_MSB ); IntToStr( BLUE_Data, dataTxt ); mikrobus_logWrite( "BLUE data : ", _LOG_TEXT ); mikrobus_logWrite( dataTxt, _LOG_TEXT ); mikrobus_logWrite( " nm", _LOG_LINE ); IR_Data = color5_readData( _COLOR5_REG_OUT_DATA_IR_MSB ); IntToStr( IR_Data, dataTxt ); mikrobus_logWrite( "IR data : ", _LOG_TEXT ); mikrobus_logWrite( dataTxt, _LOG_TEXT ); mikrobus_logWrite( " nm", _LOG_LINE ); mikrobus_logWrite("---------------rn", _LOG_LINE); if (color5_getInterrupt() == 1) { mikrobus_logWrite("Proximity detect", _LOG_LINE); } Delay_ms( 500 ); }
The full application code, and ready to use projects can be found on our
LibStock page.
Other mikroE Libraries used in the example:
- Conversions
- I2C
- UART
Additional Notes and Information
Depending on the development board you are using, you may need a USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.
MIKROSDK
The Color 5 Click Board™ is supported with mikroSDK - MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant click board demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
Color 5 Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.