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: 2019-04-19
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Proximity
Downloaded: 3954 times
Not followed.
License: MIT license
Proximity 9 click is a very accurate and reliable proximity sensing (PS) and ambient light sensing (ALS) device, equipped with the VCNL4040, an integrated PS and ALS sensor.
Do you want to subscribe in order to receive notifications regarding "Proximity 9 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Proximity 9 click" changes.
Do you want to report abuse regarding "Proximity 9 click".
Library Description
This library allows user to get Proximity output data in the desired resolution and ALS output data calculated to lux. User also can configure the ALS sensitivity by changing the ALS integration time. This library also offers a choice to check a desired interrupt flags to be sure which interrupt is generated. For more details check documentation.
Key functions:
T_PROXIMITY9_RETVAL proximity9_readReg( uint8_t regAddr, uint16_t *dataOut )
- This function reads a 16bit data from the desired register.T_PROXIMITY9_RETVAL proximity9_writeReg( uint8_t regAddr, uint16_t dataIn )
- This function writes a 16bit data to the desired register.float proximity9_get_ALS_lux( void )
- This function allows user to get the ALS value calculated to lux.Examples description
The application is composed of the three sections :
void applicationTask()
{
als_data = proximity9_get_ALS_lux();
proximity9_readReg( _PROXIMITY9_PS_DATA_REG, &prox_data );
int_check = proximity9_check_int_flag( _PROXIMITY9_PS_IF_CLOSE_FLAG | _PROXIMITY9_PS_IF_AWAY_FLAG );
FloatToStr( als_data, text );
mikrobus_logWrite( "** ALS : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( " lux", _LOG_LINE );
WordToStr( prox_data, text );
mikrobus_logWrite( "** PROXIMITY : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_LINE );
if (int_check == _PROXIMITY9_PS_IF_CLOSE_FLAG)
{
mikrobus_logWrite( "** Object is close!", _LOG_LINE );
mikrobus_logWrite( "************************************", _LOG_LINE );
Sound_Play( 1200, 50 );
Delay_ms( 50 );
Sound_Play( 1200, 50 );
Delay_ms( 50 );
Sound_Play( 1200, 50 );
}
if (int_check == _PROXIMITY9_PS_IF_AWAY_FLAG)
{
mikrobus_logWrite( "** Object is away!", _LOG_LINE );
mikrobus_logWrite( "************************************", _LOG_LINE );
Sound_Play( 1100, 100 );
Delay_ms( 50 );
Sound_Play( 1100, 100 );
}
if (int_check == _PROXIMITY9_INT_CLEARED)
{
mikrobus_logWrite( "************************************", _LOG_LINE );
Delay_ms( 200 );
}
}
Other mikroE Libraries used in the example:
I2C
UART
Conversions
Sound
Additional notes and informations
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.