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-08-20
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Proximity
Downloaded: 2523 times
Not followed.
License: MIT license
Proximity 10 Click is a versatile proximity detection device on a Click board. It can detect a foreign object distanced up to 200cm.
Do you want to subscribe in order to receive notifications regarding "Proximity 10 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Proximity 10 click" changes.
Do you want to report abuse regarding "Proximity 10 click".
Library Description
This library allows user to measure proximity between object and sensor. Also the ALS, temperature and VDD measurement can be performed in the same time and on the same way. The entire control of the Proximity 10 Click board can be perfomed by using this library, by writing to the registers, reading from the registers, writing desired parameters, checking the response, interrupt status checking and sending a commands. For more details check documentation.
Key functions:
T_PROXIMITY10_RETVAL proximity10_readBytes( uint8_t regAddr, uint8_t *dataOut, uint8_t nBytes )
- This function reads the desired number od bytes from the registers..T_PROXIMITY10_RETVAL proximity10_writeByte( uint8_t regAddr, uint8_t dataIn )
- This function writes a one byte data to the desired register.T_PROXIMITY10_RETVAL proximity10_send_command( uint8_t _command )
- This function allows user to execute a desired command and checks the response.Examples description
The application is composed of three sections :
void applicationTask()
{
proximity10_readWord( _PROXIMITY10_PS1_DATA_REG, &proximity );
WordToStr( proximity, text );
mikrobus_logWrite( "** Proximity PS1 : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_LINE );
int_status = proximity10_check_int_status( _PROXIMITY10_PS1_INT_FLAG, _PROXIMITY10_INT_CLEAR_DIS );
if (int_status == _PROXIMITY10_PS1_INT_FLAG)
{
mikrobus_logWrite( "** Object is detected **", _LOG_LINE );
alarm_dur = proximity / 100;
alarm_dur = alarm_dur + 35;
alarm_dur = (float)(alarm_dur * 0.30928);
alarm_dur = 180 - alarm_dur;
Sound_Play( 1400, alarm_dur );
Delay_ms( 100 );
}
else
{
Delay_ms( 200 );
}
mikrobus_logWrite( "**************************************", _LOG_LINE );
}
Additional Functions :
Other mikroE Libraries used in the example:
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.