You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/05.nicla/boards/nicla-vision/tutorials/proximity/content.md
+19-14
Original file line number
Diff line number
Diff line change
@@ -16,12 +16,11 @@ software:
16
16
- cli
17
17
---
18
18
19
-

19
+
## Overview
20
20
21
21
In this tutorial you will use the Nicla Vision to detect proximity, thanks to the Time of Flight (ToF) sensor **VL53L1X**.
22
22
23
-
This tutorial contains the sketch to blink the built-in RGB LED and control the speed of its blink by the proximity values.
24
-
This could help for future projects and control the Camera only when something is crossing in front of the board, like a proximity detector.
23
+
This tutorial goes through how to create a sketch that will blink the built-in RGB LED and control the speed of its blink with the proximity values. It can be useful for future projects where there is a need to control the camera only when something is detected in front of the sensor.
25
24
26
25
***The Arduino sketch shown is available inside the `Arduino_Pro_Tutorials` library by going to `Examples > Nicla Vision > Proximity_Blink***
27
26
@@ -31,20 +30,22 @@ The goals of this project are:
31
30
- Learn how to interact with the proximity readings
32
31
- Change the RGB values of the LED
33
32
34
-
35
33
### Required Hardware and Software
36
34
37
35
* Arduino Nicla Vision
38
-
* VL53L1X library (Available on the Library Manager)
36
+
* VL53L1X library (Available in the Library Manager)
37
+
38
+
## Instructions
39
+
40
+
### Time of Flight Sensor
39
41
40
-
## Blink Depending on the Distance
42
+

41
43
42
-
Make sure you have installed the latest version of **Arduino mbed Core** and the **VL53L1X library**.
44
+
To make sure that the sketch works properly, the latest versions of the **Arduino mbed Core** and the **VL53L1X library** needs to be installed. The **Arduino mbed Core** can be found in the **boards manager...** and the **VL53L1X library** can be found in the **Library manager**, both can be found inside the Arduino IDE.
43
45
44
46
### Include the Needed Libraries and Objects Declaration
45
47
46
-
First of all declare the sensor's class so you can access it later on your sketch.
47
-
The variables are to avoid using delays as the reading would not be accurate.
48
+
First of all declare the sensor's class so you can access it later on in your sketch. We use variables to control the time elements in the sketch. This will make sure that the readings stay accurate over time.
48
49
49
50
```cpp
50
51
#include<Wire.h>
@@ -56,14 +57,13 @@ The variables are to avoid using delays as the reading would not be accurate.
56
57
int timeStart = 0;
57
58
int blinkTime = 2000;
58
59
```
59
-
***Make sure you set `Wire1` inside the VL53L1X constructor's parameter, it won't work if you don't add that setting***
60
+
***Make sure you set `Wire1` inside the VL53L1X constructor's parameter, it won't work if you don't add this setting***
60
61
61
62
### Initialize the Proximity Sensor and the LED
62
63
63
-
Inside the setup you need to initialize the proximity sensor.
64
-
Also the RGB LED needs to be set as an output to make it light up.
64
+
Inside the setup you need to initialize and configure the proximity sensor. Also the RGB LED needs to be set as an output to make it light up and enable us to change its behavior.
65
65
66
-
***The LEDs are accessed as the Portenta H7: LEDR, LEDG and LEDB***
66
+
***The LEDs are accessed in the same way as on the Portenta H7: LEDR, LEDG and LEDB***
67
67
68
68
```cpp
69
69
void setup(){
@@ -86,7 +86,7 @@ Also the RGB LED needs to be set as an output to make it light up.
86
86
87
87
### Control the Speed of the Blink
88
88
89
-
The sketch is going to get the reading on every loop, store it and then the state of the LED will change until the time is up until the proximity reading.
89
+
The sketch is going to get the reading on every loop, store it and then the state of the LED will change, until the time is up and another proximity reading is taken.
90
90
91
91
```cpp
92
92
voidloop(){
@@ -162,3 +162,8 @@ The sketch is going to get the reading on every loop, store it and then the stat
162
162
| setTimeout(mSeconds) | Configure the milliseconds the sensor will wait in case it is not getting the proper reading to abort, and continue with a new one, 0 disables it. |`void`|
163
163
| getTimeout() | Get the configured timeout value. |`uint16_t`|
164
164
| timeoutOccurred() | Returns true whenever the sensor had a timeout. |`bool`|
165
+
166
+
167
+
## Conclusion
168
+
169
+
In this tutorial we went through how to get readings from the ToF sensor. And how use these readings to change how the built-in LED behaves. At the end of the tutorial you can also find a reference list for the ToF library.
0 commit comments