You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
562 B

  1. import serial
  2. import time
  3. arduino = serial.Serial('/dev/ttyACM0', 115200, timeout=.1)
  4. def move(locations):
  5. reps = 0
  6. for i in range(0,len(locations),2):
  7. while(arduino.read() != "1"):
  8. arduino.write(locations[i])
  9. time.sleep(0.25)
  10. arduino.flushInput()
  11. arduino.flushOutput()
  12. while(arduino.read() != '1'):
  13. arduino.write(locations[i+1])
  14. time.sleep(0.25)
  15. arduino.flushInput()
  16. arduino.flushOutput()
  17. arduino.write('-')
  18. move(['1','3','2','1','3','2'])