Skip to content

Commit 11e374e

Browse files
authored
Tutorial Minor revamp (#1701)
1 parent ed38a1e commit 11e374e

File tree

2 files changed

+40
-34
lines changed

2 files changed

+40
-34
lines changed

content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/content.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ In this tutorial you will use the Nicla Vision to detect proximity, thanks to th
2222

2323
This tutorial teaches you 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 the need to control the camera only when something is detected in front of the sensor.
2424

25-
***The Arduino sketch shown is available inside the `Arduino_Pro_Tutorials` library by going to Examples > Nicla Vision > Proximity_Blink***
26-
2725
## Goals
2826

2927
- Set up the needed libraries
@@ -41,24 +39,24 @@ This tutorial teaches you how to create a sketch that will blink the built-in RG
4139

4240
![Arduino Nicla Vision - Time of Flight sensor](assets/nicla-vision-tof.png)
4341

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. Both can be found inside the Arduino IDE.
42+
To make sure that the sketch works properly, the latest versions of the **Arduino Mbed OS Nicla** core and the **VL53L1X library** need to be installed. Both can be found inside the Arduino IDE.
4543

46-
- The **Arduino mbed Core** can be found in the **boards manager...**.
47-
- The **VL53L1X library** can be found in the **Library manager**,
44+
- The **Arduino Mbed OS Nicla** core can be found in the **boards manager...**
45+
- The **VL53L1X library** can be found in the **Library manager**
4846

49-
If you are using version 1.6.2 or later of the Arduino software (IDE), you can use the Library Manager to install the VL53L1X library:
47+
If you are using version 2.2.0 or later of the Arduino IDE, install the VL53L1X library as follows:
5048

51-
- In the Arduino IDE, open the "Sketch" menu, select "Include Library", then "Manage Libraries...".
52-
- Search for "VL53L1X".
49+
- In the left bar of the Arduino IDE, click on the **Library Manager**.
50+
- Search for **VL53L1X**.
5351
- Click the VL53L1X entry in the list, authored by Pololu.
54-
- Click "Install". More detailed instructions on how to install a library can be found [here](/learn/starting-guide/software-libraries).
52+
- Click **Install**. More detailed instructions on how to install a library can be found [here](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-installing-a-library/).
5553

5654

5755
### Include the Needed Libraries and Objects Declaration
5856

5957
First of all, declare the sensor's class so you can access it later on in your sketch. You can use variables to control the time elements in the sketch. This will make sure that the readings stay accurate over time.
6058

61-
```cpp
59+
```arduino
6260
#include "VL53L1X.h"
6361
VL53L1X proximity;
6462
@@ -70,11 +68,11 @@ int blinkTime = 2000;
7068

7169
### Initialize the Proximity Sensor and the LED
7270

73-
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 you to change its behavior.
71+
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 you to change its behavior.
7472

7573
***The LEDs are accessed in the same way as on the Portenta H7: LEDR, LEDG and LEDB.***
7674

77-
```cpp
75+
```arduino
7876
void setup(){
7977
Serial.begin(115200);
8078
Wire1.begin();
@@ -95,13 +93,13 @@ Inside the setup you need to initialize and configure the proximity sensor. Also
9593
}
9694
```
9795

98-
***Make sure you initialize `Wire1`, set the clock speed to 400 kHz and set the bus pointer to `Wire1`. It will not work if you do not add these setting.***
96+
***Make sure you initialize `Wire1`, set the clock speed to 400 kHz and set the bus pointer to `Wire1`. It will not work if you do not add these settings.***
9997

10098
### Control the Speed of the Blink
10199

102-
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.
100+
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.
103101

104-
```cpp
102+
```arduino
105103
void loop(){
106104
reading = proximity.read();
107105
Serial.println(reading);
@@ -117,7 +115,7 @@ The sketch is going to get the reading on every loop, store it and then the stat
117115

118116
### Complete Sketch
119117

120-
```cpp
118+
```arduino
121119
#include "VL53L1X.h"
122120
VL53L1X proximity;
123121
@@ -159,26 +157,34 @@ void loop() {
159157
}
160158
```
161159

160+
Here is a demo video of the example running on the Nicla Vision:
161+
162+
<div style="text-align: center;">
163+
<video width="100%" controls="true">
164+
<source src="assets/proximity.mp4" type="video/mp4"/>
165+
</video>
166+
</div>
167+
162168
## API
163-
| Command | Details | type |
164-
| :----------------------------------- | :----------------------------------------------------------: | :---------------- |
165-
| setAddress(newAddress) | Change the I2C sensor's address (Mandatory to set it to `Wire1`) | `void` |
166-
| getAddress() | Get the Sensor's I2C address | `uint8_t` |
167-
| init() | Configures the sensor and needed data. Like the usual begin()| `void` |
168-
| setDistanceMode(mode) | Set the distance mode (check the datasheet). Available modes `VL53L1X::Short`, `VL53L1X::Medium`, `VL53L1X::Long`, `VL53L1X::Unknown` | `void` |
169-
| getDistanceMode() | Returns the mode that has been set. Available modes `VL53L1X::Short`, `VL53L1X::Medium`, `VL53L1X::Long`, `VL53L1X::Unknown`| `enum DistanceMode ` |
170-
| setMeasurementTimingBudget(uSeconds) | Set the time to get the measure, greater the value, better precision. In micro seconds. | `void` |
171-
| getMeasurementTimingBudget() | Get the measure timing value in micro seconds. | `uint32_t` |
172-
| startContinuous() | Start the non stop readings, set the period inside the parameter, after that time you will get the reading. | `void` |
173-
| stopContinuous() | Stop the non stop measurements. | `void` |
174-
| read() | Get the last reading from the continuous mode. | `void` |
175-
| readSingle() | Trigger one reading and get its result. | `uint16_t` |
176-
| dataReady() | Returns if the sensor has new data available. | `bool` |
177-
| 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` |
178-
| getTimeout() | Get the configured timeout value. | `uint16_t` |
179-
| timeoutOccurred() | Returns true whenever the sensor had a timeout. | `bool` |
169+
| Command | Details | type |
170+
|:-------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------|
171+
| setAddress(newAddress) | Change the I2C sensor's address (Mandatory to set it to `Wire1`) | `void` |
172+
| getAddress() | Get the Sensor's I2C address | `uint8_t` |
173+
| init() | Configures the sensor and needed data. Like the usual begin() | `void` |
174+
| setDistanceMode(mode) | Set the distance mode (check the datasheet). Available modes `VL53L1X::Short`, `VL53L1X::Medium`, `VL53L1X::Long`, `VL53L1X::Unknown` | `void` |
175+
| getDistanceMode() | Returns the mode that has been set. Available modes `VL53L1X::Short`, `VL53L1X::Medium`, `VL53L1X::Long`, `VL53L1X::Unknown` | `enum DistanceMode ` |
176+
| setMeasurementTimingBudget(uSeconds) | Set the time to get the measure, greater the value, better precision. In micro seconds. | `void` |
177+
| getMeasurementTimingBudget() | Get the measure timing value in micro seconds. | `uint32_t` |
178+
| startContinuous() | Start the non stop readings, set the period inside the parameter, after that time you will get the reading. | `void` |
179+
| stopContinuous() | Stop the non stop measurements. | `void` |
180+
| read() | Get the last reading from the continuous mode. | `void` |
181+
| readSingle() | Trigger one reading and get its result. | `uint16_t` |
182+
| dataReady() | Returns if the sensor has new data available. | `bool` |
183+
| 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` |
184+
| getTimeout() | Get the configured timeout value. | `uint16_t` |
185+
| timeoutOccurred() | Returns true whenever the sensor had a timeout. | `bool` |
180186

181187

182188
## Conclusion
183189

184-
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.
190+
In this tutorial we went through how to get readings from the ToF sensor and how to 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

Comments
 (0)