Skip to content

Commit 4f15175

Browse files
committed
ModulinoDistance: fix examples for new API
1 parent 08d2495 commit 4f15175

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

examples/Modulino_Distance/Basic/Basic.ino

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ void setup() {
99
}
1010

1111
void loop() {
12-
int measure = distance.get();
13-
Serial.println(measure);
12+
if (distance.available()) {
13+
int measure = distance.get();
14+
Serial.println(measure);
15+
}
1416
delay(10);
1517
}

examples/Utilities/Modulino_PlugNPlay/Modulino_PlugNPlay.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void loop() {
4040
skip = (skip + 1) % 5;
4141
}
4242

43-
pitch = encoder.get() + distance.get();
43+
pitch = encoder.get() + (distance.available() ? distance.get() : 0);
4444

4545
if (Serial.available() && Serial.read() == 's') {
4646
imu.update();

0 commit comments

Comments
 (0)