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-03-15
Package Version: 1.0.0.1
mikroSDK Library: 1.0.0.0
Category: Proximity
Downloaded: 4422 times
Followed by: 4 users
License: MIT license
Proximity 2 clickâ„¢ features MAX44000, an IC that integrates an ambient light as well as a proximity sensor. The IR proximity detector is matched with an integrated IR LED driver (for the onboard high power infrared LED). Proximity 2 clickâ„¢ communicates with the target board microcontroller through mikroBUS I2C (SCL, SDA), and INT lines.
Do you want to subscribe in order to receive notifications regarding "Proximity 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Proximity 2 click" changes.
Do you want to report abuse regarding "Proximity 2 click".
Front and back side appearance of the Proximity 2 Click Board.
View full imageLibrary Description
The library initializes and defines the I2C bus driver and drivers that offer a choice for writing and reading
data in and from registers. The library includes a functions for reading interrupt state, main configuration,
receive configuration, transmit configuration, ambient light and proximity registers. It allows to it's user
many diferent setings and set ups in order tu make full usage of its capabilities.
Key functions:
uint8_t proximity2_readProxDataReg();
- Function is used to read prox data register in order to get data on distance from sensor to an object.Examples description
The application is composed of three sections:
void applicationTask() { proxiVal = proximity2_readProxDataReg(); ambient = proximity2_readAlsDataRegs(); if ( ( ( proxiVal - proxiValOld ) > sensitivity ) || ( ( proxiValOld - proxiVal ) > sensitivity ) ) { mikrobus_logWrite( " Distance : ", _LOG_TEXT ); IntToStr( proxiVal, txt ); Ltrim( txt ); mikrobus_logWrite( txt, _LOG_LINE ); mikrobus_logWrite( " Light : ", _LOG_TEXT ); IntToStr( ambient, txt ); Ltrim( txt ); mikrobus_logWrite( txt, _LOG_LINE ); mikrobus_logWrite( "-------------------", _LOG_LINE ); proxiValOld = proxiVal; Delay_ms( 1 ); } }
Other mikroE Libraries used in the example:
I2C
UART
Conversion
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