diff --git a/content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/assets/proximity.mp4 b/content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/assets/proximity.mp4 new file mode 100644 index 0000000000..fcb67c4584 Binary files /dev/null and b/content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/assets/proximity.mp4 differ diff --git a/content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/content.md b/content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/content.md index 328e62b4d7..b8b40d584b 100644 --- a/content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/content.md +++ b/content/hardware/06.nicla/boards/nicla-vision/tutorials/proximity/content.md @@ -22,8 +22,6 @@ In this tutorial you will use the Nicla Vision to detect proximity, thanks to th 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. -***The Arduino sketch shown is available inside the `Arduino_Pro_Tutorials` library by going to Examples > Nicla Vision > Proximity_Blink*** - ## Goals - 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  -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. +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. -- The **Arduino mbed Core** can be found in the **boards manager...**. -- The **VL53L1X library** can be found in the **Library manager**, +- The **Arduino Mbed OS Nicla** core can be found in the **boards manager...** +- The **VL53L1X library** can be found in the **Library manager** -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: +If you are using version 2.2.0 or later of the Arduino IDE, install the VL53L1X library as follows: -- In the Arduino IDE, open the "Sketch" menu, select "Include Library", then "Manage Libraries...". -- Search for "VL53L1X". +- In the left bar of the Arduino IDE, click on the **Library Manager**. +- Search for **VL53L1X**. - Click the VL53L1X entry in the list, authored by Pololu. -- Click "Install". More detailed instructions on how to install a library can be found [here](/learn/starting-guide/software-libraries). +- 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/). ### Include the Needed Libraries and Objects Declaration 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. -```cpp +```arduino #include "VL53L1X.h" VL53L1X proximity; @@ -70,11 +68,11 @@ int blinkTime = 2000; ### Initialize the Proximity Sensor and the LED -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. +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. ***The LEDs are accessed in the same way as on the Portenta H7: LEDR, LEDG and LEDB.*** -```cpp +```arduino void setup(){ Serial.begin(115200); Wire1.begin(); @@ -95,13 +93,13 @@ Inside the setup you need to initialize and configure the proximity sensor. Also } ``` -***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.*** +***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.*** ### Control the Speed of the Blink -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. +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. -```cpp +```arduino void loop(){ reading = proximity.read(); Serial.println(reading); @@ -117,7 +115,7 @@ The sketch is going to get the reading on every loop, store it and then the stat ### Complete Sketch -```cpp +```arduino #include "VL53L1X.h" VL53L1X proximity; @@ -159,26 +157,34 @@ void loop() { } ``` +Here is a demo video of the example running on the Nicla Vision: + +