LightRanger 10 Click
LightRanger 10 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : May 2022.
- Type : I2C type
Software Support
Example Description
This example demonstrates the use of LightRanger 10 Click board by reading and displaying the target object distance in millimeters.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.LightRanger10
Example Key Functions
- lightranger10_cfg_setup Config Object Initialization function.
void lightranger10_cfg_setup(lightranger10_cfg_t *cfg)
LightRanger 10 configuration object setup function.
LightRanger 10 Click configuration object.
Definition lightranger10.h:231
- lightranger10_init Initialization function.
err_t lightranger10_init(lightranger10_t *ctx, lightranger10_cfg_t *cfg)
LightRanger 10 initialization function.
LightRanger 10 Click context object.
Definition lightranger10.h:211
- lightranger10_default_cfg Click Default Configuration function.
err_t lightranger10_default_cfg(lightranger10_t *ctx)
LightRanger 10 default configuration function.
- lightranger10_get_int_pin This function returns the INT pin logic state.
uint8_t lightranger10_get_int_pin(lightranger10_t *ctx)
LightRanger 10 get int pin function.
- lightranger10_clear_interrupts This function clears the interrupts.
err_t lightranger10_clear_interrupts(lightranger10_t *ctx)
LightRanger 10 clear interrupts function.
- lightranger10_get_distance This function reads the target object distance in millimeters.
err_t lightranger10_get_distance(lightranger10_t *ctx, uint16_t *distance_mm)
LightRanger 10 get distance function.
Application Init
Initializes the driver, performs the Click default configuration, and then calibrates the sensor to the object positioned at 200mm distance from the sensor.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_printf( &logger, " --- Sensor calibration --- \r\n" );
log_printf( &logger, " Place an object at 200mm distance from sensor in the next 5 seconds.\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, " Sensor calibration is in progress...\r\n" );
{
log_error( &logger, " Sensor calibration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define LIGHTRANGER10_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition lightranger10.h:197
err_t lightranger10_calibrate_distance(lightranger10_t *ctx, uint16_t target_distance_mm)
LightRanger 10 calibrate distance function.
@ LIGHTRANGER10_ERROR
Definition lightranger10.h:250
void application_init(void)
Definition main.c:30
Application Task
Waits for the data ready interrupt, then clears the interrupt and reads the target distance in millimeters and displays the results on the USB UART every 200ms approximately.
{
uint16_t distance_mm;
{
log_printf ( &logger, " Distance: %u mm \r\n\n", distance_mm );
}
}
@ LIGHTRANGER10_OK
Definition lightranger10.h:249
void application_task(void)
Definition main.c:80
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.