We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2018-07-27
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Optical
Downloaded: 4108 times
Not followed.
License: MIT license
Color 5 click is a color sensing Click board, which utilizes the P12347-01CT, integrated color sensing device, which can sense red (R), green (G), and blue (B) component of the light, providing measurement via I2C interface.
Do you want to subscribe in order to receive notifications regarding "Color 5 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Color 5 click" changes.
Do you want to report abuse regarding "Color 5 click".
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 sensorvoid color5_setLedDriver(uint8_t red, uint8_t green, uint8_t blue)
- Functions for setting led coloruint16_t color5_readData(uint8_t reg)
- Functions for reading data from registeruint8_t color5_getInterrupt()
- Functions for proximity detectExample description
The application is composed of three sections :
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 );
}
Other mikroE Libraries used in the example:
Additional notes and information
Depending on the development board you are using, you may need 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.