|
| 1 | + |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +# IR_Distance Click |
| 6 | + |
| 7 | +- **CIC Prefix** : IRDISTANCE |
| 8 | +- **Author** : Nenad Filipovic |
| 9 | +- **Verison** : 1.0.0 |
| 10 | +- **Date** : Mar 2019. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | + |
| 15 | +### Software Support |
| 16 | + |
| 17 | +We provide a library for the IR_Distance Click on our [LibStock](https://libstock.mikroe.com/projects/view/1581/ir-distance-click) |
| 18 | +page, as well as a demo application (example), developed using MikroElektronika |
| 19 | +[compilers](http://shop.mikroe.com/compilers). The demo can run on all the main |
| 20 | +MikroElektronika [development boards](http://shop.mikroe.com/development-boards). |
| 21 | + |
| 22 | +**Library Description** |
| 23 | + |
| 24 | +The library covers all the necessary functions to control IR Distance click board. |
| 25 | +IR Distance click communicates with the target board via analog ( AN ) pin. |
| 26 | +This library contains drivers for read ADC value of the Sharp’s GP2Y0A60SZ0F distance measuring sensor |
| 27 | +on IR Distance click board. |
| 28 | + |
| 29 | +Key functions : |
| 30 | + |
| 31 | +- ``` void irdistance_enable() ``` - Enable IR sensor function. |
| 32 | +- ``` void irdistance_disable() ``` - Disable IR sensor function. |
| 33 | +- ``` float irdistance_getVoltageOut( uint32_t adcValue, uint16_t resolutionValue, float vccValue ) ``` - Get the voltage output of the sensor function. |
| 34 | + |
| 35 | +**Examples Description** |
| 36 | + |
| 37 | +The application is composed of three sections : |
| 38 | + |
| 39 | +- System Initialization - Initializes GPIO and LOG structures, |
| 40 | + sets AN pin as input, RST pin as output and starts write log. |
| 41 | +- Application Initialization - Initialization driver enables GPIO, |
| 42 | + enable IR sensor, initialization ADC, also write log. |
| 43 | +- Application Task - (code snippet) This is an example which demonstrates the use of IR Distance click board. |
| 44 | + IR Distance click reads and displays ADC value. |
| 45 | + Results are being sent to the Usart Terminal where you can track their changes. |
| 46 | + All data logs on USB uart change for every 1 sec. |
| 47 | + |
| 48 | + |
| 49 | +```.c |
| 50 | + |
| 51 | +void applicationTask() |
| 52 | +{ |
| 53 | + adcVal = irdistance_readADC(); |
| 54 | + WordToStr( adcVal, logText ); |
| 55 | + |
| 56 | + mikrobus_logWrite( " ADC value : ", _LOG_TEXT ); |
| 57 | + mikrobus_logWrite( logText, _LOG_LINE ); |
| 58 | + mikrobus_logWrite( "-------------------", _LOG_LINE ); |
| 59 | + Delay_1sec(); |
| 60 | +} |
| 61 | + |
| 62 | +``` |
| 63 | + |
| 64 | +Additional Functions : |
| 65 | + |
| 66 | +- ``` void irdistance_adcInit() ``` - Function ADC initialization. |
| 67 | +- ``` uint32_t irdistance_readADC() ``` - Function read ADC value. |
| 68 | + |
| 69 | +The full application code, and ready to use projects can be found on our |
| 70 | +[LibStock](https://libstock.mikroe.com/projects/view/1581/ir-distance-click) page. |
| 71 | + |
| 72 | +Other mikroE Libraries used in the example: |
| 73 | + |
| 74 | +- ADC |
| 75 | +- UART |
| 76 | +- Conversion |
| 77 | + |
| 78 | +**Additional notes and informations** |
| 79 | + |
| 80 | +Depending on the development board you are using, you may need |
| 81 | +[USB UART click](http://shop.mikroe.com/usb-uart-click), |
| 82 | +[USB UART 2 Click](http://shop.mikroe.com/usb-uart-2-click) or |
| 83 | +[RS232 Click](http://shop.mikroe.com/rs232-click) to connect to your PC, for |
| 84 | +development systems with no UART to USB interface available on the board. The |
| 85 | +terminal available in all Mikroelektronika |
| 86 | +[compilers](http://shop.mikroe.com/compilers), or any other terminal application |
| 87 | +of your choice, can be used to read the message. |
| 88 | + |
| 89 | +--- |
| 90 | +--- |
0 commit comments