How does it work?
IR Distance Click is based on the GP2Y0A60SZ0F, a distance-measuring sensor unit from Sharp. The sensor provides a voltage corresponding to the detection distance, which is why it can also be used as a proximity sensor. The triangulation method of measuring the distance means the determination of the location of an object by forming triangles to the point of known points. In the case of the GP2Y0A60SZ0F, the IR LED emits a narrow light beam and, after reflecting from an object, is directed to the sensor lens of the PSD. Depending on the object, the angle of the reflected light will be different. The conductivity of the PSD depends on the position where the reflected beam falls and afterward is converted to the voltage, where the distance can be calculated using an analog-digital converter.
The IR Distance Click communicates with the host MCU by sending analog values over the OUT pin of the mikroBUS™ socket. The OUT pin provides information to the MCU about the presence of an object and its distance, where the output of the distance sensor is inversely proportional, meaning that when the distance grows, the output decreases. The main control pin of the sensor can be accessed over the EN pin of the mikroBUS™ socket, thus enabling the sensor to work.
This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the PWR SEL jumpers. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Note that all the jumpers’ positions must be on the same side, or the Click board™ may become unresponsive. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.
Specifications
Type
Optical
Applications
Can be used for touch-less switches, sensors for energy saving, amusement equipment, and more
On-board modules
GP2Y0A60SZ0F – distance-measuring sensor unit from Sharp
Key Features
10 to 150cm measurement range, with triangulation method to measure the distance, sensor consists of PSD, IR LED, and signal processing, analog output type, low power consumption, and more
Interface
Analog,GPIO
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
3.3V or 5V
Pinout diagram
This table shows how the pinout on IR Distance Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
– | PWR | – | Power LED Indicator |
SEL1A-SEL2A | PWR SEL | – | Logic Level Voltage Selection 3V3/5V: Left position 3V3, Right position 5V |
IR Distance Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | – | 3.3 | – | V |
Distance Measurement Range | 10 | – | 150 | cm |
Wavelength | – | 870 | – | nm |
Software Support
We provide a library for the IR distance Click as well as a demo application (example), developed using Mikroe compilers. The demo can run on all the main Mikroe development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager (recommended), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for IR distance Click driver.
Key functions
-
Function enable distance measuring sensor by set RST pin on Stretch click board.
-
This function reads ADC data using analog_in_read function
-
Function calculate the voltage output of distance measuring sensor on IR Distance click board.
Example Description
The click board outputs an analog voltage corresponding to the distance of the object (through the mikroBUS AN pin). An Enable (EN) pin is also utilized.
void application_task ( void )
{
adc_val = irdistance_read_adc( &irdistance );
log_printf( &logger, " ADC value : %urn", adc_val );
log_printf( &logger, "---------------------rn" );
Delay_ms( 1000 );
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager (recommended), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.IrDistance
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. UART terminal is available in all Mikroe compilers.
mikroSDK
This Click board™ is supported with mikroSDK – Mikroe Software Development Kit, that needs to be downloaded from the LibStock and installed for the compiler you are using to ensure proper operation of mikroSDK compliant Click board™ demo applications.
For more information about mikroSDK, visit the official page.