Refactor seat belt logic for clarity
This commit is contained in:
1 parent
0a4a0b862c
commit
7585dfe3e9
1 file changed
+6
-4
+6
-4
@@ -82,10 +82,12 @@ void loop() {
|
||||
if (millis() - prevSonarUpdate >= 100) {
|
||||
prevSonarUpdate = millis();
|
||||
long dist = sonar.measure();
|
||||
if (!seatBelts)
|
||||
if (dist < 200)
|
||||
seatBelts = true;
|
||||
else if (dist >= 200) seatBelts = true;
|
||||
if (!seatBelts) {
|
||||
if (dist < 200) seatBelts = true;
|
||||
}
|
||||
else {
|
||||
if (dist >= 200) seatBelts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user