Skip to content

Commit 77e25d1

Browse files
committed
Fix code blocks
1 parent 0ba391d commit 77e25d1

File tree

1 file changed

+40
-40
lines changed
  • content/hardware/05.nicla/boards/nicla-vision/tutorials/proximity

1 file changed

+40
-40
lines changed

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

+40-40
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ To make sure that the sketch works properly, the latest versions of the **Arduin
4848
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.
4949

5050
```cpp
51-
#include <Wire.h>
52-
#include "VL53L1X.h"
53-
VL53L1X proximity(Wire1);
54-
55-
bool blinkState = false;
56-
int reading = 0;
57-
int timeStart = 0;
58-
int blinkTime = 2000;
51+
#include <Wire.h>
52+
#include "VL53L1X.h"
53+
VL53L1X proximity(Wire1);
54+
55+
bool blinkState = false;
56+
int reading = 0;
57+
int timeStart = 0;
58+
int blinkTime = 2000;
5959
```
6060
***Make sure you set `Wire1` inside the VL53L1X constructor's parameter, it won't work if you don't add this setting***
6161
@@ -105,43 +105,43 @@ The sketch is going to get the reading on every loop, store it and then the stat
105105
### Complete Sketch
106106
107107
```cpp
108-
#include <Wire.h>
109-
#include "VL53L1X.h"
110-
VL53L1X proximity(Wire1);
111-
112-
bool blinkState = false;
113-
int reading = 0;
114-
int timeStart = 0;
115-
int blinkTime = 2000;
116-
117-
void setup(){
118-
Serial.begin(115200);
119-
Wire1.begin();
120-
121-
pinMode(LEDB,OUTPUT);
122-
digitalWrite(LEDB, blinkState);
123-
124-
if (!proximity.init()){
125-
Serial.println("Failed to detect and initialize sensor!");
126-
while (1);
127-
}
128-
129-
proximity.setDistanceMode(VL53L1X::Long);
130-
proximity.setMeasurementTimingBudget(10000);
131-
proximity.startContinuous(10);
108+
#include <Wire.h>
109+
#include "VL53L1X.h"
110+
VL53L1X proximity(Wire1);
111+
112+
bool blinkState = false;
113+
int reading = 0;
114+
int timeStart = 0;
115+
int blinkTime = 2000;
116+
117+
void setup(){
118+
Serial.begin(115200);
119+
Wire1.begin();
120+
121+
pinMode(LEDB,OUTPUT);
122+
digitalWrite(LEDB, blinkState);
123+
124+
if (!proximity.init()){
125+
Serial.println("Failed to detect and initialize sensor!");
126+
while (1);
132127
}
133128
134-
void loop(){
135-
reading = proximity.read();
136-
Serial.println(reading);
129+
proximity.setDistanceMode(VL53L1X::Long);
130+
proximity.setMeasurementTimingBudget(10000);
131+
proximity.startContinuous(10);
132+
}
137133
138-
if (millis() - timeStart >= reading){
139-
digitalWrite(LEDB, blinkState);
140-
timeStart = millis();
134+
void loop(){
135+
reading = proximity.read();
136+
Serial.println(reading);
141137
142-
blinkState = !blinkState;
143-
}
138+
if (millis() - timeStart >= reading){
139+
digitalWrite(LEDB, blinkState);
140+
timeStart = millis();
141+
142+
blinkState = !blinkState;
144143
}
144+
}
145145
```
146146

147147
## API

0 commit comments

Comments
 (0)