Skip to content

Commit

Permalink
updated ultrasonic function
Browse files Browse the repository at this point in the history
  • Loading branch information
valenmoore committed May 8, 2024
1 parent 515c6db commit f640360
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ def read_data(self, val):
# don't try more than 3 times
for i in range(0, 2, 1):
self.ser.reset_input_buffer()
data = self.ser.readline()
try:
count = 0
data = None
while data is None and count <= 3:
count = count + 1
data = self.ser.readline()
except:

d = data.decode()
if d[0] == "$":
d = d[1:]
Expand Down

0 comments on commit f640360

Please sign in to comment.