The following code works fine in Bloxter, but not in Python. I currently have DexterOS 2.2.2.
import easygopigo3 as easy
import time
gpg = easy.EasyGoPiGo3()
try:
my_linefollower = gpg.init_line_follower()
time.sleep(0.1)
except:
print('Line Follower not responding')
time.sleep(0.2)
exit()
my_linefollower.read_position()
my_linefollower.read_position()
"""Describe this function...
"""
def follow_line():
gpg.set_eye_color((255,0,0))
gpg.open_eyes()
gpg.close_eyes()
if not ((my_linefollower.read_position() == "black") or (my_linefollower.read_position() == "white")):
gpg.open_eyes()
gpg.forward()
while not (my_linefollower.read_position() == "black") or (my_linefollower.read_position() == "white"):
if my_linefollower.read_position() == 'center':
gpg.forward()
if my_linefollower.read_position() == 'left':
gpg.left()
if my_linefollower.read_position() == 'right':
gpg.right()
gpg.stop()
gpg.close_eyes()
# start
while True:
follow_line()
time.sleep(0.05) # slowdown