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-10-29
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Optical
Downloaded: 4150 times
Not followed.
License: MIT license
Color 8 click is a color-sensing Click board™, a part of our sensor Click board line. Sensing the color by utilizing ROHM’s BH1749NUC, an integrated color sensor IC, it comes in the package which also includes the mikroSDK software, a library with all the functions.
Do you want to subscribe in order to receive notifications regarding "Color 8 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Color 8 click" changes.
Do you want to report abuse regarding "Color 8 click".
Library Description
The library initializes and defines the I2C bus driver and drivers that offer a choice for writing data in register and reads data from register. The library includes function for configuration chip for measurement, function for reads one color and functions for light color value is received by calculating RGB value and conversions in HSL value. The user also has the function color8_getColor() which checks the color of the light.
Key functions:
void float color8_getColorValue()
- Functions for read color value in HSLvoid uint8_t color8_getColor(float color_value)
- Function for set output voltageExamples description
The application is composed of the three sections :
void applicationTask()
{
RED_data = color8_readData(_COLOR8_REG_RED_DATA);
IntToStr(RED_data, demoText);
mikrobus_logWrite(" RED data : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_LINE);
GREEN_data = color8_readData(_COLOR8_REG_GREEN_DATA);
IntToStr(GREEN_data, demoText);
mikrobus_logWrite(" GREEN data : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_LINE);
BLUE_data = color8_readData(_COLOR8_REG_BLUE_DATA);
IntToStr(BLUE_data, demoText);
mikrobus_logWrite(" BLUE data : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_LINE);
IR_data = color8_readData(_COLOR8_REG_IR_DATA);
IntToStr(IR_data, demoText);
mikrobus_logWrite(" IR data : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_LINE);
colorValue = color8_getColorValue();
FloatToStr(colorValue, demoText);
mikrobus_logWrite(" HSL color value : ", _LOG_TEXT);
mikrobus_logWrite(demoText, _LOG_LINE);
isColor = color8_getColor(colorValue);
switch(isColor)
{
case 1:
{
mikrobus_logWrite("--- Color: ORANGE ", _LOG_LINE);
break;
}
case 2:
{
mikrobus_logWrite("--- Color: RED ", _LOG_LINE);
break;
}
case 3:
{
mikrobus_logWrite("--- Color: PINK ", _LOG_LINE);
break;
}
case 4:
{
mikrobus_logWrite("--- Color: PURPLE ", _LOG_LINE);
break;
}
case 5:
{
mikrobus_logWrite("--- Color: BLUE ", _LOG_LINE);
break;
}
case 6:
{
mikrobus_logWrite("--- Color: CYAN ", _LOG_LINE);
break;
}
case 7:
{
mikrobus_logWrite("--- Color: GREEN ", _LOG_LINE);
break;
}
case 8:
{
mikrobus_logWrite("--- Color: YELLOW ", _LOG_LINE);
break;
}
default:
{
break;
}
}
Delay_100ms();
mikrobus_logWrite(" ", _LOG_LINE);
Delay_ms( 1000 );
}
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.