From a274c954876877ff333b485a6348364501886244 Mon Sep 17 00:00:00 2001 From: h-bauer <84972893+h-bauer@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:56:27 +0200 Subject: [PATCH] Raise error on light value > 1024 The continue statement in the inner for loop had no effect on the outer for loop. The use of break skips the new else clause, forcing a new try (if available). --- Line_Follower.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Line_Follower.py b/Line_Follower.py index 1705f5f..614c16f 100644 --- a/Line_Follower.py +++ b/Line_Follower.py @@ -34,8 +34,9 @@ def read_analog(self, trys=5): low_byte = raw_result[i*2+1] analog_result[i] = high_byte + low_byte if analog_result[i] > 1024: - continue - return analog_result + break + else: + return analog_result else: raise IOError("Line follower read error. Please check the wiring.")