Пытаюсь отправить команду Arduino Start drive
и получаю ошибку:
Traceback (most recent call last):
File "moveMotors.py", line 289, in <module>
main()
File "moveMotors.py", line 285, in main
followTheLine()
File "moveMotors.py", line 250, in followTheLine
moveMotors(maxMotorPWM, maxMotorPWM - pid)
File "moveMotors.py", line 80, in moveMotors
serialArduino.write(struct.pack('>B', right))
struct.error: required argument is not an integer
Я использую Python3
этот код на Python.
def moveMotors(left, right):
'''Moves the motors with specific speed'''
if (0 < left <= 255) or (0 < right <= 255):
serialArduino.write(struct.pack('>B', 254)) # code 254 for moveStright() function on Arduino
serialArduino.write(struct.pack('>B', left))
serialArduino.write(struct.pack('>B', right))
elif left == 0 and right == 0:
serialArduino.write(struct.pack('>B', 253)) # code 253 for stop() function on Arduino
else:
print ("Speed must be an integer between 0 and 255.\n")