TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (137101 times)
  2. FAT32 Library (70236 times)
  3. Network Ethernet Library (56126 times)
  4. USB Device Library (46434 times)
  5. Network WiFi Library (42079 times)
  6. FT800 Library (41389 times)
  7. GSM click (29116 times)
  8. mikroSDK (26562 times)
  9. PID Library (26503 times)
  10. microSD click (25487 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

Proximity 10 click

Rating:

5

Author: MIKROE

Last Updated: 2019-08-20

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Proximity

Downloaded: 2177 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.

No Abuse Reported

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".

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

Proximity 10 click

Proximity 10 click

Native view of the Proximity 10 click board.

View full image
Proximity 10 click

Proximity 10 click

Front and back view of the Proximity 10 click board.

View full image

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 :

  • System Initialization - Initializes peripherals and pins.
  • Application Initialization - Initializes I2C serial interface and performs a device wake up, reset and all necessary configurations. The device will wake up and performs a measurements every 10 milliseconds.
  • Application Task - (code snippet) - Reads the proximity PS1 data value and sends result to the uart terminal. If measured proximity value is greater than selected proximity threshold value, the interrupt will be generated and the message will be showed on the uart terminal. When interrupt is generated the Sound function will make an alarm sound with determined duration depending on the detected proximity value, how much is object away or close from the sensor.
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 :

  • checkResponse - Sends an error code message to the uart terminal if error code is detected in the response.

Other mikroE Libraries used in the example:

  • Conversions
  • I2C
  • UART
  • Sound

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB 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.

ALSO FROM THIS AUTHOR

Magneto 13 click

0

Magneto 13 Click is a compact add-on board with an accurate and reliable magnetic device. This board features the MA736, a contactless digital angle sensor from Monolithic Power Systems. It is a MagAlpha sensor that detects the absolute angular position of a permanent magnet, typically a diametrically magnetized cylinder or a rotating shaft. The MA736 sensor supports a wide range of magnetic field strengths, end-of-shaft, and side-shaft (off-axis mounting) spatial configurations.

[Learn More]

CAN SPI 3.3V click

0

This is code that shows simple connection of two CAN SPI modules with SN65HVD230.<br/> Messages are sent by pressing PortB buttons and received message can be seen on PortD LEDs.<br/>

[Learn More]

4x4 RGB click

0

4x4 RGB click is a matrix of 16 intelligent RGB elements, forming a 4x4 display screen.

[Learn More]